public static Props addCommonFlowProperties(final Props parentProps, final ExecutableFlowBase flow) { final Props props = new Props(parentProps); props.put(CommonJobProperties.FLOW_ID, flow.getFlowId()); props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId()); props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId()); props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName()); props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion()); props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp()); props.put(CommonJobProperties.SUBMIT_USER, flow.getExecutableFlow().getSubmitUser()); final DateTime loadTime = new DateTime(); props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString()); props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy")); props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM")); props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd")); props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH")); props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm")); props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss")); props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS")); props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ")); return props; }
private ExecutableNode getExecutableNodePath(final ExecutableFlowBase flow, final String[] ids, int currentIdIdx) { final ExecutableNode node = flow.getExecutableNode(ids[currentIdIdx]); currentIdIdx++; if (node == null) { return null; } if (ids.length == currentIdIdx) { return node; } else if (node instanceof ExecutableFlowBase) { return getExecutableNodePath((ExecutableFlowBase) node, ids, currentIdIdx); } else { return null; } }
public String getFlowPath() { if (this.getParentFlow() == null) { return this.getFlowId(); } else { return this.getParentFlow().getFlowPath() + "," + this.getId() + ":" + this.getFlowId(); } } }
final ExecutableFlowBase exFlow = new ExecutableFlowBase(); exFlow.fillExecutableFromMapObject(wrapper); exFlow.setParentFlow(this); this.executableNodes.put(exFlow.getId(), exFlow); } else { final ExecutableNode exJob = new ExecutableNode();
(ExecutableFlowBase) exFlow.getExecutableNode("jobd"); Assert.assertEquals("innerFlow", jobbFlow.getFlowId()); Assert.assertEquals("jobb", jobbFlow.getId()); Assert.assertEquals(4, jobbFlow.getExecutableNodes().size()); Assert.assertEquals("innerFlow", jobcFlow.getFlowId()); Assert.assertEquals("jobc", jobcFlow.getId()); Assert.assertEquals(4, jobcFlow.getExecutableNodes().size()); Assert.assertEquals("innerFlow", jobdFlow.getFlowId()); Assert.assertEquals("jobd", jobdFlow.getId()); Assert.assertEquals(4, jobdFlow.getExecutableNodes().size());
new ArrayList<>(); for (final ExecutableNode subNode : base.getExecutableNodes()) { final Map<String, Object> subNodeObj = getExecutableFlowUpdateInfo(subNode, lastUpdateTime); nodeObj.put("flow", base.getFlowId()); nodeObj.put("nodes", nodeList);
final ExecutableFlowBase exB = (ExecutableFlowBase) b; Assert.assertEquals(exA.getFlowId(), exB.getFlowId()); Assert.assertEquals(exA.getExecutableNodes().size(), exB .getExecutableNodes().size()); for (final ExecutableNode nodeA : exA.getExecutableNodes()) { final ExecutableNode nodeB = exB.getExecutableNode(nodeA.getId()); Assert.assertNotNull(nodeB); Assert.assertEquals(a, nodeA.getParentFlow());
private void finalizeFlow(ExecutableFlowBase flow) { String id = flow == this.flow ? "" : flow.getNestedId(); Props previousOutput = null; for (String end: flow.getEndNodes()) { ExecutableNode node = flow.getExecutableNode(end); flow.setOutputProps(previousOutput); if (!succeeded && (flow.getStatus() == Status.RUNNING)) { flow.setStatus(Status.KILLED); flow.setEndTime(System.currentTimeMillis()); flow.setUpdateTime(System.currentTimeMillis()); long durationSec = (flow.getEndTime() - flow.getStartTime()) / 1000; switch(flow.getStatus()) { case FAILED_FINISHING: logger.info("Setting flow '" + id + "' status to FAILED in " + durationSec + " seconds"); flow.setStatus(Status.FAILED); break; case FAILED: case CANCELLED: case FAILED_SUCCEEDED: logger.info("Flow '" + id + "' is set to " + flow.getStatus().toString() + " in " + durationSec + " seconds"); break; default: flow.setStatus(Status.SUCCEEDED); logger.info("Flow '" + id + "' is set to " + flow.getStatus().toString() + " in " + durationSec + " seconds");
public static Props addCommonFlowProperties(Props parentProps, final ExecutableFlowBase flow) { Props props = new Props(parentProps); props.put(CommonJobProperties.FLOW_ID, flow.getFlowId()); props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId()); props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId()); props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion()); props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString()); DateTime loadTime = new DateTime(); props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString()); props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy")); props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM")); props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd")); props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH")); props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm")); props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss")); props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS")); props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ")); return props; }
for (String id : flow.getEndNodes()) { ExecutableNode node = flow.getExecutableNode(id); queue.add(node); switch (base.getStatus()) { case CANCELLED: node.setStatus(Status.READY); ExecutableNode nodeUp = flow.getExecutableNode(inId); queue.add(nodeUp); Status oldFlowState = flow.getStatus(); if (maxStartTime == -1) { flow.setStatus(Status.READY); flow.setStatus(Status.RUNNING); for (String id: flow.getStartNodes()) { ExecutableNode node = flow.getExecutableNode(id); if (node.getStatus() == Status.READY || node.getStatus() == Status.DISABLED) { nodesToRetry.add(node); flow.setUpdateTime(System.currentTimeMillis()); flow.setEndTime(-1); flow.setStartTime(maxStartTime); logger.info("Resetting flow '" + flow.getNestedId() + "' from " + oldFlowState + " to " + flow.getStatus());
/** * Change job status to disabled in exflow if the job is in disabledJobs */ public static void applyDisabledJobs(final List<Object> disabledJobs, final ExecutableFlowBase exflow) { for (final Object disabled : disabledJobs) { if (disabled instanceof String) { final String nodeName = (String) disabled; final ExecutableNode node = exflow.getExecutableNode(nodeName); if (node != null) { node.setStatus(Status.DISABLED); } } else if (disabled instanceof Map) { final Map<String, Object> nestedDisabled = (Map<String, Object>) disabled; final String nodeName = (String) nestedDisabled.get("id"); final List<Object> subDisabledJobs = (List<Object>) nestedDisabled.get("children"); if (nodeName == null || subDisabledJobs == null) { return; } final ExecutableNode node = exflow.getExecutableNode(nodeName); if (node != null && node instanceof ExecutableFlowBase) { applyDisabledJobs(subDisabledJobs, (ExecutableFlowBase) node); } } } }
page.add("parentflowid", node.getParentFlow().getFlowId()); page.add("jobname", node.getId());
if (node instanceof ExecutableFlowBase) { ExecutableFlowBase flow = ((ExecutableFlowBase) node); logger.info("Running flow '" + flow.getNestedId() + "'."); flow.setStatus(Status.RUNNING); flow.setStartTime(System.currentTimeMillis()); prepareJobProperties(flow); for (String startNodeId: ((ExecutableFlowBase) node).getStartNodes()) { ExecutableNode startNode = flow.getExecutableNode(startNodeId); runReadyJob(startNode);
ExecutableFlowBase parentFlow = node.getParentFlow(); if (parentFlow.getEndNodes().contains(node.getId())) { if (!parentFlow.getOutNodes().isEmpty()) { ExecutableFlowBase grandParentFlow = parentFlow.getParentFlow(); for (String outNode: parentFlow.getOutNodes()) { ExecutableNode nextNode = grandParentFlow.getExecutableNode(outNode); ExecutableNode nextNode = parentFlow.getExecutableNode(outNode);
public void applyUpdateObject(final Map<String, Object> updateData, final List<ExecutableNode> updatedNodes) { final TypedMapWrapper<String, Object> typedMapWrapper = new TypedMapWrapper<>(updateData); applyUpdateObject(typedMapWrapper, updatedNodes); }
public void reEnableDependents(final ExecutableNode... nodes) { for (final ExecutableNode node : nodes) { for (final String dependent : node.getOutNodes()) { final ExecutableNode dependentNode = getExecutableNode(dependent); if (dependentNode.getStatus() == Status.KILLED) { dependentNode.setStatus(Status.READY); dependentNode.setUpdateTime(System.currentTimeMillis()); reEnableDependents(dependentNode); if (dependentNode instanceof ExecutableFlowBase) { ((ExecutableFlowBase) dependentNode).reEnableDependents(); } } else if (dependentNode.getStatus() == Status.SKIPPED) { dependentNode.setStatus(Status.DISABLED); dependentNode.setUpdateTime(System.currentTimeMillis()); reEnableDependents(dependentNode); } } } }
outNodeIds = parentFlow.getOutNodes(); parentFlow = parentFlow.getParentFlow(); ExecutableNode outNode = parentFlow.getExecutableNode(nodeId); nodesToCheck.add(outNode);
public ExecutableNode getExecutableNodePath(final String... ids) { return getExecutableNodePath(this, ids, 0); }
ArrayList<ExecutableNode> jobsToRun = new ArrayList<ExecutableNode>(); if (isFlowFinished() && !Status.isStatusFinished(getStatus())) { jobsToRun.add(this); jobsToRun.addAll(((ExecutableFlowBase)node).findNextJobsToRun()); for (String dependency: node.getInNodes()) { if (!Status.isStatusFinished(getExecutableNode(dependency).getStatus())) { continue nodeloop;
public ExecutableFlow getExecutableFlow() { if (this.parentFlow == null) { return null; } return this.parentFlow.getExecutableFlow(); }