use of org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent in project airavata by apache.
the class WorkflowInterpreter method executeDynamically.
private void executeDynamically(final Node node) throws WorkflowException, TException, RegistryException, AiravataException {
node.setState(NodeExecutionState.EXECUTING);
invokedNode.add(node);
updateWorkflowNodeStatus(nodeInstanceList.get(node), WorkflowNodeState.EXECUTING);
publishNodeStatusChange(WorkflowNodeState.EXECUTING, node.getID(), experiment.getExperimentID());
Component component = node.getComponent();
if (component instanceof SubWorkflowComponent) {
handleSubWorkComponent(node);
} else if (component instanceof WSComponent) {
handleWSComponent(node);
} else if (component instanceof DynamicComponent) {
handleDynamicComponent(node);
} else if (component instanceof ForEachComponent) {
handleForEach(node);
} else if (component instanceof IfComponent) {
handleIf(node);
} else if (component instanceof EndifComponent) {
handleEndIf(node);
} else if (component instanceof DoWhileComponent) {
handleDoWhile(node);
} else if (component instanceof EndDoWhileComponent) {
// Component is handled in DoWhileHandler after eval condition
} else if (component instanceof InstanceComponent) {
handleAmazonInstance(node);
} else if (component instanceof TerminateInstanceComponent) {
handleAmazonTerminateInstance(node);
} else {
throw new WorkFlowInterpreterException("Encountered Node that cannot be executed:" + node);
}
}
use of org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent in project airavata by apache.
the class WorkflowInterpreter method getReadyNodesDynamically.
private ArrayList<Node> getReadyNodesDynamically() {
ArrayList<Node> list = new ArrayList<Node>();
ArrayList<Node> waiting = InterpreterUtil.getWaitingNodesDynamically(this.getGraph());
// ArrayList<Node> finishedNodes = InterpreterUtil.getFinishedNodesDynamically(this.getGraph());
// This is to support repeat the same application in the workflow.
List<String> finishedNodeIds = InterpreterUtil.getFinishedNodesIds(this.getGraph());
for (Node node : waiting) {
Component component = node.getComponent();
if (component instanceof WSComponent || component instanceof DynamicComponent || component instanceof SubWorkflowComponent || component instanceof ForEachComponent || component instanceof EndForEachComponent || component instanceof IfComponent || component instanceof InstanceComponent) {
/*
* Check for control ports from other node
*/
ControlPort control = node.getControlInPort();
boolean controlDone = true;
if (control != null) {
for (EdgeImpl edge : control.getEdges()) {
controlDone = controlDone && (finishedNodeIds.contains(edge.getFromPort().getNode().getID()) || // that makes sense and if anyone found a scenario it should be otherwise pls fix
((ControlPort) edge.getFromPort()).isConditionMet());
}
}
/*
* Check for input ports
*/
List<DataPort> inputPorts = node.getInputPorts();
boolean inputsDone = true;
for (DataPort dataPort : inputPorts) {
inputsDone = inputsDone && finishedNodeIds.contains(dataPort.getFromNode().getID());
}
if (inputsDone && controlDone) {
list.add(node);
}
} else if (component instanceof EndifComponent) {
/*
* EndIfComponent can run if number of input equals to number of
* output that it expects
*/
int expectedOutput = node.getOutputPorts().size();
int actualInput = 0;
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort dataPort : inputPorts) {
if (finishedNodeIds.contains(dataPort.getFromNode().getID()))
actualInput++;
}
if (expectedOutput == actualInput) {
list.add(node);
}
} else if (component instanceof TerminateInstanceComponent) {
/*
* All node connected to controlIn port must be done
*/
ControlPort control = node.getControlInPort();
boolean controlDone = true;
if (control != null) {
for (EdgeImpl edge : control.getEdges()) {
controlDone = controlDone && finishedNodeIds.contains(edge.getFromPort().getFromNode().getID());
}
}
/*
* Check for input ports
*/
List<DataPort> inputPorts = node.getInputPorts();
boolean inputsDone = true;
for (DataPort dataPort : inputPorts) {
inputsDone = inputsDone && finishedNodeIds.contains(dataPort.getFromNode().getID());
}
if (inputsDone && controlDone) {
list.add(node);
}
} else if (InputComponent.NAME.equals(component.getName()) || DifferedInputComponent.NAME.equals(component.getName()) || S3InputComponent.NAME.equals(component.getName()) || OutputComponent.NAME.equals(component.getName()) || MemoComponent.NAME.equals(component.getName()) || component instanceof EndDoWhileComponent) {
// no op
} else if (component instanceof DoWhileComponent) {
ControlPort control = node.getControlInPort();
boolean controlDone = true;
if (control != null) {
for (EdgeImpl edge : control.getEdges()) {
controlDone = controlDone && finishedNodeIds.contains(edge.getFromPort().getFromNode().getID());
}
}
if (controlDone) {
list.add(node);
}
} else {
throw new WorkFlowInterpreterException("Component Not handled :" + component.getName());
}
}
notifyViaInteractor(WorkflowExecutionMessage.HANDLE_DEPENDENT_NODES_DIFFERED_INPUTS, this.getGraph());
return list;
}
use of org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent in project airavata by apache.
the class TerminateInstanceNode method getComponent.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#getComponent()
*/
@Override
public Component getComponent() {
Component component = super.getComponent();
if (component == null) {
// The component is null when read from the graph XML.
component = new TerminateInstanceComponent();
setComponent(component);
}
return component;
}
Aggregations