@Override public String toString() { return MessageFormat.format( "Flow'{'id={0}, blockers={1}, scripts={2}'}'", getId(), getBlockerIds(), getScripts()); } }
private static JsonObject analyzeJobflow(FlowScript flowScript) { assert flowScript != null; JsonArray phases = new JsonArray(); for (Map.Entry<ExecutionPhase, Set<ExecutionScript>> entry : flowScript.getScripts().entrySet()) { ExecutionPhase phase = entry.getKey(); if (entry.getValue().isEmpty() == false || phase == ExecutionPhase.SETUP || phase == ExecutionPhase.CLEANUP) { phases.add(new JsonPrimitive(phase.getSymbol())); } } JsonObject jobflow = new JsonObject(); jobflow.addProperty("id", flowScript.getId()); jobflow.add("blockers", toJsonArray(flowScript.getBlockerIds())); jobflow.add("phases", phases); return jobflow; }
private void executePhase( String batchId, FlowScript flow, String executionId, ExecutionPhase phase) throws InterruptedException, IOException { ExecutionContext context = newContext(batchId, flow.getId(), executionId, phase); Set<ExecutionScript> scripts = flow.getScripts().get(phase); assert scripts != null; executePhase(context, scripts, flow.getEnabledScriptKinds()); }
properties.setProperty(flowPrefix + KEY_BLOCKERS, join(getBlockerIds())); properties.setProperty(flowPrefix + KEY_ENABLED_SCRIPT_KINDS, join(toSymbols(getEnabledScriptKinds()))); for (Map.Entry<ExecutionPhase, Set<ExecutionScript>> phase : getScripts().entrySet()) { int index = 0; for (ExecutionScript script : phase.getValue()) {
/** * Executes a target phase. * @param context the current context * @throws InterruptedException if interrupted during this execution * @throws IOException if failed to execute target phase * @throws IllegalArgumentException if some parameters were {@code null} * @since 0.2.5 */ public void executePhase(ExecutionContext context) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } FlowScript flow = script.findFlow(context.getFlowId()); if (flow == null) { throw new IllegalArgumentException(MessageFormat.format( "Flow is undefined: batchId={0}, flowId={1}, executionId={2}", context.getBatchId(), context.getFlowId(), context.getExecutionId())); } Set<ExecutionScript> executions = flow.getScripts().get(context.getPhase()); try (ExecutionLock lock = acquireExecutionLock(context.getBatchId())) { lock.beginFlow(context.getFlowId(), context.getExecutionId()); executePhase(context, executions, flow.getEnabledScriptKinds()); lock.endFlow(context.getFlowId(), context.getExecutionId()); } }