public boolean pauseWorkflowRun() { setState(State.paused); if (Stop.pauseWorkflow(getWorkflowRunId())) { logger.info("Paused workflow runId=" + getWorkflowRunId() + " processId=" + instanceOwningProcessId); return true; } return false; }
/** * Resume the workflow run with the specified id on this Stop layer. This * method processes any suspended job events. * * @param workflowRunId * The id of the workflow run to resume. */ private void resumeLayerWorkflow(String workflowRunId) { synchronized (Stop.class) { for (DispatchJobEvent dje : suspendedJobEventMap .remove(workflowRunId)) { this.receiveJob(dje); } } }
/** * Resume the workflow run with the specified id * * @param workflowRunId * The id of the workflow run to resume * @return If the workflow run was resumed then true. If the workflow run * was not paused or it was cancelled, then false. */ public static synchronized boolean resumeWorkflow(String workflowRunId) { if (cancelledWorkflowRuns.contains(workflowRunId)) { return false; } if (pausedLayerMap.containsKey(workflowRunId)) { Map<String, Set<Stop>> pausedLayerMapCopy = new HashMap<String, Set<Stop>>(); pausedLayerMapCopy.putAll(pausedLayerMap); Set<Stop> stops = pausedLayerMapCopy.remove(workflowRunId); pausedLayerMap = pausedLayerMapCopy; for (Stop s : stops) { s.resumeLayerWorkflow(workflowRunId); } return true; } else { return false; } }
@Override public DispatchLayer<?> createDispatchLayer(URI uri) { DispatchLayer<?> dispatchLayer = null; if (parallelizeLayer.equals(uri)) { dispatchLayer = new Parallelize(); } else if (errorBounceLayer.equals(uri)) { dispatchLayer = new ErrorBounce(); } else if (failoverLayer.equals(uri)) { dispatchLayer = new Failover(); } else if (retryLayer.equals(uri)) { dispatchLayer = new Retry(); } else if (invokeLayer.equals(uri)) { dispatchLayer = new Invoke(); } else if (loopLayer.equals(uri)) { dispatchLayer = new Loop(); } else if (intermediateProvenanceLayer.equals(uri)) { dispatchLayer = new IntermediateProvenance(); } else if (stopLayer.equals(uri)) { dispatchLayer = new Stop(); } return dispatchLayer; }
public boolean resumeWorkflowRun() { setState(State.running); if (Stop.resumeWorkflow(getWorkflowRunId())) { logger.info("Resumed paused workflow runId=" + getWorkflowRunId() + " processId=" + instanceOwningProcessId); return true; } return false; }
public synchronized boolean cancelWorkflowRun() { if (getState().equals(State.completed)) { return false; } boolean result = Stop.cancelWorkflow(getWorkflowRunId()); if (result) { setState(State.cancelled); logger.info("Cancelled workflow runId=" + getWorkflowRunId() + " processId=" + instanceOwningProcessId); List<FailureListener> copyOfListeners = null; synchronized (failureListeners) { copyOfListeners = new ArrayList<FailureListener>(failureListeners); } for (FailureListener failureListener : copyOfListeners) { try { failureListener.workflowFailed("Workflow was cancelled", new WorkflowRunCancellation(getWorkflowRunId())); } catch (RuntimeException ex) { logger.warn("Could not notify failure listener " + failureListener, ex); } } processorsToComplete = 0; portsToComplete = 0; checkWorkflowFinished(); } return result; }
public DefaultDispatchStackEdit(Processor processor) { super(processor); DispatchStackImpl stack = ((ProcessorImpl)processor).getDispatchStack(); // Top level parallelise layer int layer = 0; List<Edit<?>> edits = new ArrayList<Edit<?>>(); edits.add(new AddDispatchLayerEdit(stack, new Parallelize(MAX_JOBS), layer++)); edits.add(new AddDispatchLayerEdit(stack, new ErrorBounce(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Failover(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Retry(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Stop(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Invoke(), layer++)); compoundEdit=new CompoundEdit(edits); }
@SuppressWarnings("unchecked") public void deserializeDispatchStack(Processor processor, Element dispatchStack) throws ClassNotFoundException, InstantiationException, IllegalAccessException, EditException { int layers=0; for (Element layer : (List<Element>)dispatchStack.getChildren(DISPATCH_LAYER,T2_WORKFLOW_NAMESPACE)) { DispatchLayer<?> dispatchLayer = DispatchLayerXMLDeserializer.getInstance().deserializeDispatchLayer(layer); if (dispatchLayer instanceof Invoke) { edits.getAddDispatchLayerEdit(processor.getDispatchStack(), new Stop(), layers++).doEdit(); } edits.getAddDispatchLayerEdit(processor.getDispatchStack(), dispatchLayer, layers++).doEdit(); } } }