예제 #1
0
 protected static String toInfo(JobInfo info) {
   StringBuilder sb = new StringBuilder();
   sb.append("JobInfo[ ").append(info).append("]");
   if (info != null) {
     sb.append(" --> ");
     sb.append("state - ").append(info.getJobState()).append(", ");
     sb.append("output - ").append(info.getOutput()).append(", ");
     sb.append("error - ").append(info.getError());
   }
   return sb.toString();
 }
예제 #2
0
 protected JobInfo waitToFinish(final String phase, final String handle) throws Exception {
   PipelineService pipelineService = PipelineServiceFactory.newPipelineService();
   JobInfo jobInfo = getJobInfo(pipelineService, phase, handle);
   JobInfo.State state = jobInfo.getJobState();
   int N = 24; // 2min
   while (isRunning(state) && N > 0) {
     N--;
     sync(5 * 1000L); // 5sec
     // new info lookup
     jobInfo = getJobInfo(pipelineService, phase, handle);
     state = jobInfo.getJobState();
   }
   if (N == 0 && isRunning(state)) {
     throw new IllegalStateException(
         "Failed to finish the job [ " + phase + " ]: " + handle + ", info: " + toInfo(jobInfo));
   }
   if (state != JobInfo.State.COMPLETED_SUCCESSFULLY) {
     throw new IllegalStateException(
         "Job " + handle + " failed [ " + phase + " ]: " + toInfo(jobInfo));
   }
   return jobInfo;
 }