Esempio n. 1
0
 private void waitForComplete() throws InterruptedException, IOException {
   LOG.debug("Waiting for running jobflows complete: {}", batchId);
   FlowScriptTask done = doneQueue.take();
   assert done.isDone();
   FlowScript flow = done.script;
   try {
     done.get();
     boolean blocked = blocking.remove(flow.getId());
     assert blocked;
   } catch (CancellationException e) {
     YSLOG.info(e, "I01005", batchId, flow.getId());
   } catch (ExecutionException e) {
     if (e.getCause() instanceof IOException) {
       throw (IOException) e.getCause();
     } else if (e.getCause() instanceof InterruptedException) {
       throw (InterruptedException) e.getCause();
     } else if (e.getCause() instanceof Error) {
       throw (Error) e.getCause();
     } else {
       throw new IOException("Flow execution failed by unknown error", e);
     }
   } finally {
     FlowScriptTask ran = running.remove(flow.getId());
     assert ran != null;
   }
 }
Esempio n. 2
0
 public void run() throws InterruptedException, IOException {
   try {
     while (flows.isEmpty() == false) {
       boolean submitted = submit();
       if (submitted == false) {
         if (running.isEmpty()) {
           throw new IOException(
               MessageFormat.format("Deadlock was detected in \"{0}\": {1}", batchId, blocking));
         }
         waitForComplete();
       }
     }
     while (running.isEmpty() == false) {
       waitForComplete();
     }
   } finally {
     YSLOG.info("I01004", batchId);
     for (FlowScriptTask task : running.values()) {
       task.cancel(true);
     }
     while (running.isEmpty() == false) {
       try {
         waitForComplete();
       } catch (IOException e) {
         YSLOG.warn(e, "W01002", batchId);
       }
     }
   }
 }