@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(loggingContext); runningThread = Thread.currentThread(); createLocalDatasets(); workflow = initializeWorkflow(); }
@Override protected void shutDown() throws Exception { // Clear the interrupt flag. boolean interrupted = Thread.interrupted(); try { destroyWorkflow(); deleteLocalDatasets(); if (pluginInstantiator != null) { pluginInstantiator.close(); } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
private void executeNode(ApplicationSpecification appSpec, WorkflowNode node, InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) throws Exception { WorkflowNodeType nodeType = node.getType(); ((BasicWorkflowToken) token).setCurrentNode(node.getNodeId()); switch (nodeType) { case ACTION: WorkflowActionNode actionNode = (WorkflowActionNode) node; if (SchedulableProgramType.CUSTOM_ACTION == actionNode.getProgram().getProgramType()) { executeCustomAction(actionNode, instantiator, classLoader, token); } else { executeAction(actionNode, token); } break; case FORK: executeFork(appSpec, (WorkflowForkNode) node, instantiator, classLoader, token); break; case CONDITION: executeCondition(appSpec, (WorkflowConditionNode) node, instantiator, classLoader, token); break; default: break; } }
private void executeAll(Iterator<WorkflowNode> iterator, ApplicationSpecification appSpec, InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) { while (iterator.hasNext() && runningThread != null) { try { blockIfSuspended(); WorkflowNode node = iterator.next(); executeNode(appSpec, node, instantiator, classLoader, token); } catch (Throwable t) { Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof InterruptedException) { LOG.debug("Workflow '{}' with run id '{}' aborted", workflowSpec.getName(), workflowRunId.getRun()); workflowContext.setState(new ProgramState(ProgramStatus.KILLED, rootCause.getMessage())); break; } workflowContext.setState(new ProgramState(ProgramStatus.FAILED, rootCause.getMessage())); throw Throwables.propagate(rootCause); } } }
WorkflowDriver driver = new WorkflowDriver(program, options, workflowSpec, programRunnerFactory, metricsCollectionService, datasetFramework, discoveryServiceClient, txClient, workflowStateWriter, cConf, pluginInstantiator, driver.start(); return controller; } catch (Exception e) {
@Override protected void run() throws Exception { LOG.info("Starting workflow execution for '{}' with Run id '{}'", workflowSpec.getName(), workflowRunId.getRun()); LOG.trace("Workflow specification is {}", workflowSpec); workflowContext.setState(new ProgramState(ProgramStatus.RUNNING, null)); executeAll(workflowSpec.getNodes().iterator(), program.getApplicationSpecification(), new InstantiatorFactory(false), program.getClassLoader(), basicWorkflowToken); if (runningThread != null) { workflowContext.setState(new ProgramState(ProgramStatus.COMPLETED, null)); } LOG.info("Workflow '{}' with run id '{}' completed", workflowSpec.getName(), workflowRunId.getRun()); }
private void executeAction(WorkflowActionNode node, WorkflowToken token) throws Exception { status.put(node.getNodeId(), node); CountDownLatch executorTerminateLatch = new CountDownLatch(1); ExecutorService executorService = createExecutor(1, executorTerminateLatch, "action-" + node.getNodeId() + "-%d");
private void executeAll(Iterator<WorkflowNode> iterator, ApplicationSpecification appSpec, InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) { while (iterator.hasNext() && runningThread != null) { try { blockIfSuspended(); WorkflowNode node = iterator.next(); executeNode(appSpec, node, instantiator, classLoader, token); } catch (Throwable t) { Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof InterruptedException) { LOG.debug("Workflow '{}' with run id '{}' aborted", workflowSpec.getName(), workflowRunId.getRun()); workflowContext.setState(new ProgramState(ProgramStatus.KILLED, rootCause.getMessage())); break; } workflowContext.setState(new ProgramState(ProgramStatus.FAILED, rootCause.getMessage())); throw Throwables.propagate(rootCause); } } }
WorkflowDriver driver = new WorkflowDriver(program, options, workflowSpec, programRunnerFactory, metricsCollectionService, datasetFramework, discoveryServiceClient, txClient, workflowStateWriter, cConf, pluginInstantiator, driver.start(); return controller; } catch (Exception e) {
@Override protected void run() throws Exception { LOG.info("Starting workflow execution for '{}' with Run id '{}'", workflowSpec.getName(), workflowRunId.getRun()); LOG.trace("Workflow specification is {}", workflowSpec); workflowContext.setState(new ProgramState(ProgramStatus.RUNNING, null)); executeAll(workflowSpec.getNodes().iterator(), program.getApplicationSpecification(), new InstantiatorFactory(false), program.getClassLoader(), basicWorkflowToken); if (runningThread != null) { workflowContext.setState(new ProgramState(ProgramStatus.COMPLETED, null)); } LOG.info("Workflow '{}' with run id '{}' completed", workflowSpec.getName(), workflowRunId.getRun()); }
private void executeAction(WorkflowActionNode node, WorkflowToken token) throws Exception { status.put(node.getNodeId(), node); CountDownLatch executorTerminateLatch = new CountDownLatch(1); ExecutorService executorService = createExecutor(1, executorTerminateLatch, "action-" + node.getNodeId() + "-%d");
private void executeNode(ApplicationSpecification appSpec, WorkflowNode node, InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) throws Exception { WorkflowNodeType nodeType = node.getType(); ((BasicWorkflowToken) token).setCurrentNode(node.getNodeId()); switch (nodeType) { case ACTION: WorkflowActionNode actionNode = (WorkflowActionNode) node; if (SchedulableProgramType.CUSTOM_ACTION == actionNode.getProgram().getProgramType()) { executeCustomAction(actionNode, instantiator, classLoader, token); } else { executeAction(actionNode, token); } break; case FORK: executeFork(appSpec, (WorkflowForkNode) node, instantiator, classLoader, token); break; case CONDITION: executeCondition(appSpec, (WorkflowConditionNode) node, instantiator, classLoader, token); break; default: break; } }
@Override protected void startUp() throws Exception { LoggingContextAccessor.setLoggingContext(loggingContext); runningThread = Thread.currentThread(); createLocalDatasets(); workflow = initializeWorkflow(); }
@Override protected void shutDown() throws Exception { // Clear the interrupt flag. boolean interrupted = Thread.interrupted(); try { destroyWorkflow(); deleteLocalDatasets(); if (pluginInstantiator != null) { pluginInstantiator.close(); } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
executeAll(iterator, appSpec, instantiator, classLoader, token);
ExecutorService executorService = createExecutor(fork.getBranches().size(), executorTerminateLatch, "fork-" + fork.getNodeId() + "-%d"); CompletionService<Map.Entry<String, WorkflowToken>> completionService =
executeAll(iterator, appSpec, instantiator, classLoader, token);
ExecutorService executorService = createExecutor(fork.getBranches().size(), executorTerminateLatch, "fork-" + fork.getNodeId() + "-%d"); CompletionService<Map.Entry<String, WorkflowToken>> completionService =