protected void waitForJob(String jobId) {
   while (true) {
     AbstractExecutable job = jobService.getJob(jobId);
     if (job.getStatus() == ExecutableState.SUCCEED || job.getStatus() == ExecutableState.ERROR) {
       break;
     } else {
       try {
         Thread.sleep(5000);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
 }
 public void discardJob(String jobId) {
   AbstractExecutable job = getJob(jobId);
   if (job instanceof DefaultChainedExecutable) {
     List<AbstractExecutable> tasks = ((DefaultChainedExecutable) job).getTasks();
     for (AbstractExecutable task : tasks) {
       if (!task.getStatus().isFinalState()) {
         updateJobOutput(task.getId(), ExecutableState.DISCARDED, null, null);
       }
     }
   }
   updateJobOutput(jobId, ExecutableState.DISCARDED, null, null);
 }
 public void resumeJob(String jobId) {
   AbstractExecutable job = getJob(jobId);
   if (job == null) {
     return;
   }
   updateJobOutput(jobId, ExecutableState.READY, null, null);
   if (job instanceof DefaultChainedExecutable) {
     List<AbstractExecutable> tasks = ((DefaultChainedExecutable) job).getTasks();
     for (AbstractExecutable task : tasks) {
       if (task.getStatus() == ExecutableState.ERROR) {
         updateJobOutput(task.getId(), ExecutableState.READY, null, null);
         break;
       }
     }
   }
 }