Browse Source

Merge pull request #529 from boandai/dev-1.1.0

optimize poll task from zookeeper
pull/2/head
easyscheduler 5 years ago committed by GitHub
parent
commit
eb3038fdf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java

19
escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java

@ -158,7 +158,7 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue {
String taskDetail = list.get(i); String taskDetail = list.get(i);
String[] taskDetailArrs = taskDetail.split(Constants.UNDERLINE); String[] taskDetailArrs = taskDetail.split(Constants.UNDERLINE);
//向前版本兼ProcessInstanceService //forward compatibility 向前版本兼容
if(taskDetailArrs.length >= 4){ if(taskDetailArrs.length >= 4){
//format ${processInstancePriority}_${processInstanceId}_${taskInstancePriority}_${taskId} //format ${processInstancePriority}_${processInstanceId}_${taskInstancePriority}_${taskId}
@ -227,15 +227,18 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue {
String[] taskArray = formatTask.split(Constants.UNDERLINE); String[] taskArray = formatTask.split(Constants.UNDERLINE);
int processInstanceId = Integer.parseInt(taskArray[1]); int processInstanceId = Integer.parseInt(taskArray[1]);
int taskId = Integer.parseInt(taskArray[3]); int taskId = Integer.parseInt(taskArray[3]);
String suffix = "";
for(int index =4; index < taskArray.length; index++){ StringBuilder sb = new StringBuilder(50);
suffix += taskArray[index] + Constants.UNDERLINE;
}
String destTask = String.format("%s_%s_%s_%s", taskArray[0], processInstanceId, taskArray[3], taskId); String destTask = String.format("%s_%s_%s_%s", taskArray[0], processInstanceId, taskArray[3], taskId);
if(StringUtils.isNotEmpty(suffix)){
destTask += Constants.UNDERLINE + suffix; sb.append(destTask);
if(taskArray.length > 4){
for(int index = 4; index < taskArray.length; index++){
sb.append(Constants.UNDERLINE).append(taskArray[index]);
}
} }
return destTask; return sb.toString();
} }
@Override @Override

Loading…
Cancel
Save