Пример #1
0
 /**
  * 注册作业启动信息.
  *
  * @param jobExecutionShardingContext 作业运行时分片上下文
  */
 public void registerJobBegin(
     final JobExecutionMultipleShardingContext jobExecutionShardingContext) {
   if (!jobExecutionShardingContext.getShardingItems().isEmpty()
       && configService.isMonitorExecution()) {
     serverService.updateServerStatus(ServerStatus.RUNNING);
     for (int each : jobExecutionShardingContext.getShardingItems()) {
       jobNodeStorage.fillEphemeralJobNode(ExecutionNode.getRunningNode(each), "");
       jobNodeStorage.replaceJobNode(
           ExecutionNode.getLastBeginTimeNode(each), System.currentTimeMillis());
       Date nextFireTime =
           JobRegistry.getInstance().getJob(jobConfiguration.getJobName()).getNextFireTime();
       if (null != nextFireTime) {
         jobNodeStorage.replaceJobNode(
             ExecutionNode.getNextFireTimeNode(each), nextFireTime.getTime());
       }
     }
   }
 }
Пример #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();
   }
 }