Пример #1
0
 private void submit(final FlowScript flow) {
   LOG.debug("Submitting jobflow \"{}\": {}", flow.getId(), batchId);
   FlowScriptTask task =
       new FlowScriptTask(
           flow,
           doneQueue,
           new Callable<Void>() {
             @Override
             public Void call() throws InterruptedException, IOException {
               if (Thread.interrupted()) {
                 throw new InterruptedException();
               }
               String executionId = UUID.randomUUID().toString();
               LOG.debug("Generated execution ID for \"{}\": {}", flow.getId(), executionId);
               lock.beginFlow(flow.getId(), executionId);
               executeFlow(batchId, flow, executionId);
               lock.endFlow(flow.getId(), executionId);
               LOG.debug("Completing jobflow \"{}\": {}", flow.getId(), batchId);
               return null;
             }
           });
   YSLOG.info("I01003", batchId, flow.getId());
   executor.execute(task);
   running.put(flow.getId(), task);
 }
Пример #2
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;
   }
 }
Пример #3
0
 private boolean submit() {
   LOG.debug("Submitting waiting jobflows: {}", batchId);
   boolean submitted = false;
   for (Iterator<FlowScript> iter = flows.iterator(); iter.hasNext(); ) {
     FlowScript flow = iter.next();
     boolean blocked = false;
     for (String blockerId : flow.getBlockerIds()) {
       if (blocking.contains(blockerId)) {
         blocked = true;
         break;
       }
     }
     if (blocked == false) {
       submit(flow);
       iter.remove();
       submitted = true;
     }
   }
   return submitted;
 }