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; } }