如何取消集群内所有节点的后台作业的办法?

如题,我的是一个分布式集群,有3个数据节点,我在上面分别提交了一些后台运行作业,现在想取消所有节点上的后台作业,请问有什么简便的方法吗?

请先 登录 后评论

2 个回答

Jason Tang - 时序数据库技术支持

提供一种解决方案,自定义集群后台作业取消的函数:

def cancelAllJobs(){
	nodes = exec node from pnodeRun(getRecentJobs) where endTime=NULL
	jobIds = exec jobId from pnodeRun(getRecentJobs) where endTime=NULL
	print("All running jobs number is: "+size(nodes))
	if(size(nodes)>0){
		for(i in 0..(size(nodes)-1)){
			print("Start to cancel the job: "+(i+1))
			rpc(nodes[i], cancelJob{jobIds[i]})
			print("The job: "+(i+1)+" is canceled, therar are still "+(size(nodes)-i-1)+" jobs is running")
		}
	}
	do{
		print("The server is canceling the job, please wait !")
		sleep(1000)
	}
	while((exec count(*) from pnodeRun(getRecentJobs) where endTime=NULL) !=0 )
	print("cancel job finished !")
}

然后调用cancelAllJobs函数就可以了。

请先 登录 后评论
wale
/* *
*  @ brief  Cancel background jobs on any node in the cluster.
*  If id is not specified, all running background jobs in the cluster will be canceled.
*  If id is specified, running background jobs whose job IDs contain id will be canceled.
*  @ param
*  id indicates the job ID. It can be obtained by function getRecentJobs().
*  @ Return NULL
*  @ sample usage  cancelJobEx("myjob1")
*/


def cancelJobEx(id=NULL){
    if (id == NULL){// delete all jobs in the cluster
        ids = exec jobId from pnodeRun(getRecentJobs) where endTime = NULL
    }else{// delete job by JobID. 
        ids = exec jobId from pnodeRun(getRecentJobs) where endTime = NULL and jobId like(id+"%")
    }
    pnodeRun(cancelJob{ids})
}

请先 登录 后评论
  • 2 关注
  • 0 收藏,116 浏览
  • Xinhai Tang 提出于 2022-07-11 10:17

相似问题