Example #1
0
	function jobcancel() {
		//ajaxリクエスト以外
		if( !$this->RequestHandler->isAjax() ) {
			$this->set("result" , array("result" => "not ajax"));
			return;
		}

		//パラメータ解析
		$u_userid=$this->params['form']['u'];
		$u_id=$this->params['form']['id'];
		$this->log("RequestID=$u_id",LOG_DEBUG);
		if ( $u_userid == "" or $u_id == "" ){
			$this->set("result" , array("result" => "parameter error"));
			return;
		}
		CommonComponent::UpdateRunhistsResult($u_id,100);

		//ファイル名
		$out_file=DIR_RESULT."/${u_userid}/${u_id}.out";
		$pid_file=DIR_RESULT."/${u_userid}/${u_id}.pid";

		//JOBキャンセルループ
		for ($cancel_loop=0; $cancel_loop < JOBCANCEL_RETRY_MAX; $cancel_loop++){

			$cancel_loop_max=JOBCANCEL_RETRY_MAX;
			$this->log("JOB CANCEL ($cancel_loop/$cancel_loop_max)",LOG_DEBUG);

			//hiveクライアントスクリプトが完了しているか?
			if ( !file_exists($pid_file) ){
				$this->set("result" , array("result" => "ok"));
				return;
			}

			//hadoop JobID取得
			$jobid=CommonComponent::GetJobId($out_file);

			//JOBキャンセル
			if ( $jobid != "" ){
				$cmd=CMD_HADOOP." job \-kill $jobid";
				$this->log("CMD=$cmd",LOG_DEBUG);
				exec("$cmd > /dev/null 2>&1",$result,$retval);
				$this->log("CMD=$cmd => $retval",LOG_DEBUG);
			}

			sleep(JOBCANCEL_RETRY_WAIT);
		}

		$this->set("result" , array("result" => "retry over"));
	}