// 修复僵尸任务
  private void fixedDeadJob(JobPo jobPo) {
    try {
      jobPo.setIsRunning(false);
      // 1. add to executable queue
      try {
        //                application.getExecutableJobQueue().add(jobPo);
        TaskExecutableBean taskExecutable = JobDomainConverter.convertjobPotoTaskExecutable(jobPo);
        InjectorHolder.getInstance(DTaskProvider.class).addExecutableTask(taskExecutable);
      } catch (DuplicateJobException e) {
        // ignore
      }
      // 2. remove from executing queue
      //            application.getExecutingJobQueue().remove(jobPo.getJobId());
      InjectorHolder.getInstance(DTaskProvider.class)
          .deleteExecutingTaskByJobID(Long.parseLong(jobPo.getJobId()));

      //            JobLogPo jobLogPo = JobDomainConverter.convertJobLog(jobPo);
      //            jobLogPo.setSuccess(true);
      //            jobLogPo.setLevel(Level.WARN);
      //            jobLogPo.setLogType(LogType.FIXED_DEAD);
      //            application.getJobLogger().log(jobLogPo);

      TaskLogBean entity = JobDomainConverter.convertJobToTaskLog(jobPo);
      entity.setSuccess(true);
      entity.setLogType("FIXED_DEAD");
      entity.setCreateDate(new Date());
      entity.setLevel("WARN");
      // 打下日志
      InjectorHolder.getInstance(DTaskProvider.class).addTaskLog(entity);
    } catch (Throwable t) {
      LOGGER.error(t.getMessage(), t);
    }
    LOGGER.info("fix dead job ! {}", JSONUtils.toJSONString(jobPo));
  }
Esempio n. 2
0
 @Test
 public void fetchTop() throws FailStoreException {
   List<KVPair<String, Job>> kvPairs = failStore.fetchTop(5, Job.class);
   if (CollectionUtils.isNotEmpty(kvPairs)) {
     for (KVPair<String, Job> kvPair : kvPairs) {
       System.out.println(JSONUtils.toJSONString(kvPair));
     }
   }
 }