Loading escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java +4 −2 Original line number Diff line number Diff line Loading @@ -66,13 +66,15 @@ public class ExecutorController extends BaseController { @RequestParam(value = "receiversCc", required = false) String receiversCc, @RequestParam(value = "runMode", required = false) RunMode runMode, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority, @RequestParam(value = "workerGroupId", required = false) int workerGroupId, @RequestParam(value = "timeout", required = false) Integer timeout) { try { logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, " + "failure policy: {}, node name: {}, node dep: {}, notify type: {}, " + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, timeout: {}", + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, workerGroupId: {}, timeout: {}", loginUser.getUserName(), projectName, processDefinitionId, scheduleTime, failureStrategy, taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority,timeout); taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority, workerGroupId, timeout); if (timeout == null) { timeout = cn.escheduler.common.Constants.MAX_TASK_TIMEOUT; Loading escheduler-common/src/main/java/cn/escheduler/common/model/TaskNode.java +16 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,12 @@ public class TaskNode { */ private Priority taskInstancePriority; /** * worker group id */ private int workerGroupId; /** * task time out */ Loading Loading @@ -224,6 +230,7 @@ public class TaskNode { Objects.equals(extras, taskNode.extras) && Objects.equals(runFlag, taskNode.runFlag) && Objects.equals(dependence, taskNode.dependence) && Objects.equals(workerGroupId, taskNode.workerGroupId) && CollectionUtils.equalLists(depList, taskNode.depList); } Loading Loading @@ -303,6 +310,15 @@ public class TaskNode { ", dependence='" + dependence + '\'' + ", taskInstancePriority=" + taskInstancePriority + ", timeout='" + timeout + '\'' + ", workerGroupId='" + workerGroupId + '\'' + '}'; } public int getWorkerGroupId() { return workerGroupId; } public void setWorkerGroupId(int workerGroupId) { this.workerGroupId = workerGroupId; } } escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java +8 −1 Original line number Diff line number Diff line Loading @@ -54,10 +54,17 @@ public interface ITaskQueue { * an element pops out of the queue * * @param key queue name * @param remove where remove the element * @return */ String poll(String key); String poll(String key, boolean remove); /** * remove a element from queue * @param key * @param value */ void removeNode(String key, String value); /** * add an element to the set Loading escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java +21 −12 Original line number Diff line number Diff line Loading @@ -137,10 +137,11 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { * * 流程实例优先级_流程实例id_任务优先级_任务id high <- low * @param key task queue name * @param remove whether remove the element * @return the task id to be executed */ @Override public String poll(String key) { public String poll(String key, boolean remove) { try{ CuratorFramework zk = getZkClient(); String tasksQueuePath = getTasksPath(key) + Constants.SINGLE_SLASH; Loading Loading @@ -181,18 +182,11 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { String[] vals = targetTaskKey.split(Constants.UNDERLINE); try{ zk.delete().forPath(taskIdPath); // String path = conf.getString(Constants.ZOOKEEPER_SCHEDULER_ROOT) + Constants.SINGLE_SLASH + Constants.SCHEDULER_TASKS_QUEUE + "_remove" + Constants.SINGLE_SLASH + targetTaskKey; // getZkClient().create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path, // Bytes.toBytes(targetTaskKey)); }catch(Exception e){ logger.error(String.format("delete task:%s from zookeeper fail, task detail: %s exception" ,targetTaskKey, vals[vals.length - 1]) ,e); if(remove){ removeNode(key, targetTaskKey); } logger.info("consume task: {},there still have {} tasks need to be executed", targetTaskKey, size - 1); return vals[vals.length - 1]; logger.info("consume task: {},there still have {} tasks need to be executed", vals[vals.length - 1], size - 1); return targetTaskKey; }else{ logger.error("should not go here, task queue poll error, please check!"); } Loading @@ -204,6 +198,21 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { return null; } @Override public void removeNode(String key, String nodeValue){ CuratorFramework zk = getZkClient(); String tasksQueuePath = getTasksPath(key) + Constants.SINGLE_SLASH; String taskIdPath = tasksQueuePath + nodeValue; logger.info("consume task {}", taskIdPath); try{ zk.delete().forPath(taskIdPath); }catch(Exception e){ logger.error(String.format("delete task:%s from zookeeper fail, exception:" ,nodeValue) ,e); } } /** Loading escheduler-common/src/test/java/cn/escheduler/common/queue/TaskQueueImplTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -49,9 +49,9 @@ public class TaskQueueImplTest { tasksQueue.add(Constants.SCHEDULER_TASKS_QUEUE,"4"); //pop String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node1,"1"); String node2 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node2 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node2,"2"); //sadd Loading Loading @@ -99,7 +99,7 @@ public class TaskQueueImplTest { } } String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node1,"0"); //clear all data Loading Loading
escheduler-api/src/main/java/cn/escheduler/api/controller/ExecutorController.java +4 −2 Original line number Diff line number Diff line Loading @@ -66,13 +66,15 @@ public class ExecutorController extends BaseController { @RequestParam(value = "receiversCc", required = false) String receiversCc, @RequestParam(value = "runMode", required = false) RunMode runMode, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority, @RequestParam(value = "workerGroupId", required = false) int workerGroupId, @RequestParam(value = "timeout", required = false) Integer timeout) { try { logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, " + "failure policy: {}, node name: {}, node dep: {}, notify type: {}, " + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, timeout: {}", + "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, workerGroupId: {}, timeout: {}", loginUser.getUserName(), projectName, processDefinitionId, scheduleTime, failureStrategy, taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority,timeout); taskDependType, warningType, warningGroupId,receivers,receiversCc,runMode,processInstancePriority, workerGroupId, timeout); if (timeout == null) { timeout = cn.escheduler.common.Constants.MAX_TASK_TIMEOUT; Loading
escheduler-common/src/main/java/cn/escheduler/common/model/TaskNode.java +16 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,12 @@ public class TaskNode { */ private Priority taskInstancePriority; /** * worker group id */ private int workerGroupId; /** * task time out */ Loading Loading @@ -224,6 +230,7 @@ public class TaskNode { Objects.equals(extras, taskNode.extras) && Objects.equals(runFlag, taskNode.runFlag) && Objects.equals(dependence, taskNode.dependence) && Objects.equals(workerGroupId, taskNode.workerGroupId) && CollectionUtils.equalLists(depList, taskNode.depList); } Loading Loading @@ -303,6 +310,15 @@ public class TaskNode { ", dependence='" + dependence + '\'' + ", taskInstancePriority=" + taskInstancePriority + ", timeout='" + timeout + '\'' + ", workerGroupId='" + workerGroupId + '\'' + '}'; } public int getWorkerGroupId() { return workerGroupId; } public void setWorkerGroupId(int workerGroupId) { this.workerGroupId = workerGroupId; } }
escheduler-common/src/main/java/cn/escheduler/common/queue/ITaskQueue.java +8 −1 Original line number Diff line number Diff line Loading @@ -54,10 +54,17 @@ public interface ITaskQueue { * an element pops out of the queue * * @param key queue name * @param remove where remove the element * @return */ String poll(String key); String poll(String key, boolean remove); /** * remove a element from queue * @param key * @param value */ void removeNode(String key, String value); /** * add an element to the set Loading
escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java +21 −12 Original line number Diff line number Diff line Loading @@ -137,10 +137,11 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { * * 流程实例优先级_流程实例id_任务优先级_任务id high <- low * @param key task queue name * @param remove whether remove the element * @return the task id to be executed */ @Override public String poll(String key) { public String poll(String key, boolean remove) { try{ CuratorFramework zk = getZkClient(); String tasksQueuePath = getTasksPath(key) + Constants.SINGLE_SLASH; Loading Loading @@ -181,18 +182,11 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { String[] vals = targetTaskKey.split(Constants.UNDERLINE); try{ zk.delete().forPath(taskIdPath); // String path = conf.getString(Constants.ZOOKEEPER_SCHEDULER_ROOT) + Constants.SINGLE_SLASH + Constants.SCHEDULER_TASKS_QUEUE + "_remove" + Constants.SINGLE_SLASH + targetTaskKey; // getZkClient().create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path, // Bytes.toBytes(targetTaskKey)); }catch(Exception e){ logger.error(String.format("delete task:%s from zookeeper fail, task detail: %s exception" ,targetTaskKey, vals[vals.length - 1]) ,e); if(remove){ removeNode(key, targetTaskKey); } logger.info("consume task: {},there still have {} tasks need to be executed", targetTaskKey, size - 1); return vals[vals.length - 1]; logger.info("consume task: {},there still have {} tasks need to be executed", vals[vals.length - 1], size - 1); return targetTaskKey; }else{ logger.error("should not go here, task queue poll error, please check!"); } Loading @@ -204,6 +198,21 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { return null; } @Override public void removeNode(String key, String nodeValue){ CuratorFramework zk = getZkClient(); String tasksQueuePath = getTasksPath(key) + Constants.SINGLE_SLASH; String taskIdPath = tasksQueuePath + nodeValue; logger.info("consume task {}", taskIdPath); try{ zk.delete().forPath(taskIdPath); }catch(Exception e){ logger.error(String.format("delete task:%s from zookeeper fail, exception:" ,nodeValue) ,e); } } /** Loading
escheduler-common/src/test/java/cn/escheduler/common/queue/TaskQueueImplTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -49,9 +49,9 @@ public class TaskQueueImplTest { tasksQueue.add(Constants.SCHEDULER_TASKS_QUEUE,"4"); //pop String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node1,"1"); String node2 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node2 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node2,"2"); //sadd Loading Loading @@ -99,7 +99,7 @@ public class TaskQueueImplTest { } } String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE); String node1 = tasksQueue.poll(Constants.SCHEDULER_TASKS_QUEUE, false); assertEquals(node1,"0"); //clear all data Loading