status.remove(node.getNodeId()); workflowStateWriter.setWorkflowToken(workflowRunId, token);
workflowStateWriter.setWorkflowToken(workflowRunId, token); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail("action1", NodeStatus.RUNNING)); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail("action1", NodeStatus.COMPLETED));
customActionExecutor = new CustomActionExecutor(context, instantiator, classLoader); status.put(node.getNodeId(), node); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail(node.getNodeId(), NodeStatus.RUNNING)); Throwable failureCause = null; } finally { status.remove(node.getNodeId()); workflowStateWriter.setWorkflowToken(workflowRunId, token); NodeStatus status = failureCause == null ? NodeStatus.COMPLETED : NodeStatus.FAILED; nodeStates.put(node.getNodeId(), new WorkflowNodeState(node.getNodeId(), status, null, failureCause)); BasicThrowable defaultThrowable = failureCause == null ? null : new BasicThrowable(failureCause); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail(node.getNodeId(), status, null, defaultThrowable));
customActionExecutor = new CustomActionExecutor(context, instantiator, classLoader); status.put(node.getNodeId(), node); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail(node.getNodeId(), NodeStatus.RUNNING)); Throwable failureCause = null; } finally { status.remove(node.getNodeId()); workflowStateWriter.setWorkflowToken(workflowRunId, token); NodeStatus status = failureCause == null ? NodeStatus.COMPLETED : NodeStatus.FAILED; nodeStates.put(node.getNodeId(), new WorkflowNodeState(node.getNodeId(), status, null, failureCause)); BasicThrowable defaultThrowable = failureCause == null ? null : new BasicThrowable(failureCause); workflowStateWriter.addWorkflowNodeState(workflowRunId, new WorkflowNodeStateDetail(node.getNodeId(), status, null, defaultThrowable));
workflowStateWriter.setWorkflowToken(workflowRunId, token); executorService.shutdownNow();
status.remove(node.getNodeId()); workflowStateWriter.setWorkflowToken(workflowRunId, token);
workflowStateWriter.setWorkflowToken(workflowRunId, token); executorService.shutdownNow();
@SuppressWarnings("unchecked") private Workflow initializeWorkflow() throws Exception { Class<?> clz = Class.forName(workflowSpec.getClassName(), true, program.getClassLoader()); if (!Workflow.class.isAssignableFrom(clz)) { throw new IllegalStateException(String.format("%s is not Workflow.", clz)); } Class<? extends Workflow> workflowClass = (Class<? extends Workflow>) clz; final Workflow workflow = new InstantiatorFactory(false).get(TypeToken.of(workflowClass)).create(); // set metrics Reflections.visit(workflow, workflow.getClass(), new MetricsFieldSetter(workflowContext.getMetrics())); if (!(workflow instanceof ProgramLifecycle)) { return workflow; } final TransactionControl txControl = Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class, workflow, "initialize", WorkflowContext.class); basicWorkflowToken.setCurrentNode(workflowSpec.getName()); workflowContext.setState(new ProgramState(ProgramStatus.INITIALIZING, null)); workflowContext.initializeProgram((ProgramLifecycle) workflow, txControl, false); workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken); return workflow; }
@SuppressWarnings("unchecked") private Workflow initializeWorkflow() throws Exception { Class<?> clz = Class.forName(workflowSpec.getClassName(), true, program.getClassLoader()); if (!Workflow.class.isAssignableFrom(clz)) { throw new IllegalStateException(String.format("%s is not Workflow.", clz)); } Class<? extends Workflow> workflowClass = (Class<? extends Workflow>) clz; final Workflow workflow = new InstantiatorFactory(false).get(TypeToken.of(workflowClass)).create(); // set metrics Reflections.visit(workflow, workflow.getClass(), new MetricsFieldSetter(workflowContext.getMetrics())); if (!(workflow instanceof ProgramLifecycle)) { return workflow; } final TransactionControl txControl = Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class, workflow, "initialize", WorkflowContext.class); basicWorkflowToken.setCurrentNode(workflowSpec.getName()); workflowContext.setState(new ProgramState(ProgramStatus.INITIALIZING, null)); workflowContext.initializeProgram((ProgramLifecycle) workflow, txControl, false); workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken); return workflow; }
@SuppressWarnings("unchecked") private void destroyWorkflow() { if (!(workflow instanceof ProgramLifecycle)) { return; } final TransactionControl txControl = Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class, workflow, "destroy"); basicWorkflowToken.setCurrentNode(workflowSpec.getName()); workflowContext.destroyProgram((ProgramLifecycle) workflow, txControl, false); try { workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken); } catch (Throwable t) { LOG.error("Failed to store the final workflow token of Workflow {}", workflowRunId, t); } if (ProgramStatus.COMPLETED != workflowContext.getState().getStatus()) { return; } try { Set<Operation> fieldLineageOperations = workflowContext.getFieldLineageOperations(); if (!fieldLineageOperations.isEmpty()) { FieldLineageInfo info = new FieldLineageInfo(fieldLineageOperations); fieldLineageWriter.write(workflowRunId, info); } } catch (Throwable t) { LOG.debug("Failed to emit the field lineage operations for Workflow {}", workflowRunId, t); } }
@SuppressWarnings("unchecked") private void destroyWorkflow() { if (!(workflow instanceof ProgramLifecycle)) { return; } final TransactionControl txControl = Transactions.getTransactionControl(workflowContext.getDefaultTxControl(), Workflow.class, workflow, "destroy"); basicWorkflowToken.setCurrentNode(workflowSpec.getName()); workflowContext.destroyProgram((ProgramLifecycle) workflow, txControl, false); try { workflowStateWriter.setWorkflowToken(workflowRunId, basicWorkflowToken); } catch (Throwable t) { LOG.error("Failed to store the final workflow token of Workflow {}", workflowRunId, t); } if (ProgramStatus.COMPLETED != workflowContext.getState().getStatus()) { return; } try { Set<Operation> fieldLineageOperations = workflowContext.getFieldLineageOperations(); if (!fieldLineageOperations.isEmpty()) { FieldLineageInfo info = new FieldLineageInfo(fieldLineageOperations); fieldLineageWriter.write(workflowRunId, info); } } catch (Throwable t) { LOG.debug("Failed to emit the field lineage operations for Workflow {}", workflowRunId, t); } }
workflowStateWriter.setWorkflowToken(workflowRunId, token); executeAll(iterator, appSpec, instantiator, classLoader, token);
workflowStateWriter.setWorkflowToken(workflowRunId, token); executeAll(iterator, appSpec, instantiator, classLoader, token);