コード例 #1
0
 @Override
 public void handle(Job job) {
   JobExecutionInfo jobExecutionInfo = new JobExecutionInfo();
   jobExecutionInfo.setJobId(job.getId());
   jobExecutionInfo.setSlaveReceivedTime(new Date());
   job.setJobExecutionInfo(jobExecutionInfo);
   JobGroupExecutor executor = jobGroupExectuorMap.get(job.getKey().getGroup());
   executor.doJob(new JobTask(job, executor.getJobConsumer()));
   // logger.info("Submit one job for group:" + executor.getGroup());
 }
コード例 #2
0
 @Override
 public void run() {
   JobExecutionInfo jobExecutionInfo = job.getJobExecutionInfo();
   try {
     jobExecutionInfo.setSlaveJobStartTime(new Date());
     JobResult jobResult = jobConsumer.work(job);
     jobExecutionInfo.setSlaveJobEndTime(new Date());
     jobExecutionInfo.setIsSucceed(true);
     jobExecutionInfo.setJobResult(jobResult);
   } catch (RuntimeException e) {
     //
     jobExecutionInfo.setIsSucceed(false);
     jobExecutionInfo.setExecutionException(new JobExecutionException(e));
     logger.error("Execute job failed", e);
     e.printStackTrace();
   } catch (Exception e) {
     //
     jobExecutionInfo.setIsSucceed(false);
     jobExecutionInfo.setExecutionException(new JobExecutionException(e));
     logger.error("Execute job failed", e);
     e.printStackTrace();
   } finally {
     try {
       /*if(doneJobQueue.size() > TOP_TASK_SCHEDULER_SLAVE_DONE_JOB_QUEUE_SIZE / 2) {
       	node.startCommandProvider(SLAVE_PUSH_JOB_RESULT_COMMAND_PROVIDER_NAME);
       }*/
       doneJobQueue.put(jobExecutionInfo);
     } catch (InterruptedException e) {
       logger.error(e);
       e.printStackTrace();
       Thread.currentThread().interrupt();
     }
   }
 }