コード例 #1
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());
   }
 }
コード例 #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
 @Test
 public void assertGetCompletedNode() {
   assertThat(ExecutionNode.getCompletedNode(0), is("execution/0/completed"));
 }
コード例 #4
0
 /**
  * 判断该分片是否已完成.
  *
  * @param item 运行中的分片路径
  * @return 该分片是否已完成
  */
 public boolean isCompleted(final int item) {
   return jobNodeStorage.isJobNodeExisted(ExecutionNode.getCompletedNode(item));
 }