Пример #1
0
 private void fixExecutionInfo(final List<Integer> items) {
   int newShardingTotalCount = configService.getShardingTotalCount();
   int currentShardingTotalCount = items.size();
   if (newShardingTotalCount > currentShardingTotalCount) {
     for (int i = currentShardingTotalCount; i < newShardingTotalCount; i++) {
       jobNodeStorage.createJobNodeIfNeeded(ExecutionNode.ROOT + "/" + i);
     }
   } else if (newShardingTotalCount < currentShardingTotalCount) {
     for (int i = newShardingTotalCount; i < currentShardingTotalCount; i++) {
       jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.ROOT + "/" + i);
     }
   }
   jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.NECESSARY);
 }
Пример #2
0
 /** 清理作业上次运行时信息. 只会在主节点进行. */
 public void cleanPreviousExecutionInfo() {
   if (!isExecutionNodeExisted()) {
     return;
   }
   if (leaderElectionService.isLeader()) {
     jobNodeStorage.fillEphemeralJobNode(ExecutionNode.CLEANING, "");
     List<Integer> items = getAllItems();
     for (int each : items) {
       jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.getCompletedNode(each));
     }
     if (jobNodeStorage.isJobNodeExisted(ExecutionNode.NECESSARY)) {
       fixExecutionInfo(items);
     }
     jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.CLEANING);
   }
   while (jobNodeStorage.isJobNodeExisted(ExecutionNode.CLEANING)) {
     BlockUtils.waitingShortTime();
   }
 }
Пример #3
0
 /**
  * 注册作业完成信息.
  *
  * @param jobExecutionShardingContext 作业运行时分片上下文
  */
 public void registerJobCompleted(
     final JobExecutionMultipleShardingContext jobExecutionShardingContext) {
   if (!configService.isMonitorExecution()) {
     return;
   }
   serverService.updateServerStatus(ServerStatus.READY);
   for (int each : jobExecutionShardingContext.getShardingItems()) {
     jobNodeStorage.createJobNodeIfNeeded(ExecutionNode.getCompletedNode(each));
     jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.getRunningNode(each));
     jobNodeStorage.replaceJobNode(
         ExecutionNode.getLastCompleteTimeNode(each), System.currentTimeMillis());
   }
 }
Пример #4
0
 /** 删除作业执行时信息. */
 public void removeExecutionInfo() {
   jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.ROOT);
 }
Пример #5
0
 /**
  * 清除任务被错过执行的标记.
  *
  * @param items 需要清除错过执行的任务分片项
  */
 public void clearMisfire(final List<Integer> items) {
   for (int each : items) {
     jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.getMisfireNode(each));
   }
 }
Пример #6
0
 /**
  * 清除分配分片序列号的运行状态.
  *
  * <p>用于作业服务器恢复连接注册中心而重新上线的场景, 先清理上次运行时信息.
  *
  * @param items 需要清理的分片项列表
  */
 public void clearRunningInfo(final List<Integer> items) {
   for (int each : items) {
     jobNodeStorage.removeJobNodeIfExisted(ExecutionNode.getRunningNode(each));
   }
 }
 /** 删除作业失效转移信息. */
 public void removeFailoverInfo() {
   for (String each : jobNodeStorage.getJobNodeChildrenKeys(ExecutionNode.ROOT)) {
     jobNodeStorage.removeJobNodeIfExisted(
         FailoverNode.getExecutionFailoverNode(Integer.parseInt(each)));
   }
 }
 /**
  * 更新执行完毕失效转移的分片项状态.
  *
  * @param items 执行完毕失效转移的分片项列表
  */
 public void updateFailoverComplete(final List<Integer> items) {
   for (int each : items) {
     jobNodeStorage.removeJobNodeIfExisted(FailoverNode.getExecutionFailoverNode(each));
   }
 }