use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class GraphUtil method visit.
private static boolean visit(Node node, Map<Node, Color> coloredNodes) {
coloredNodes.put(node, Color.GRAY);
for (Node nextNode : getNextNodes(node)) {
Color nextNodeColor = coloredNodes.get(nextNode);
if (nextNodeColor == Color.GRAY) {
return true;
} else if (nextNodeColor == Color.WHITE) {
if (visit(nextNode, coloredNodes)) {
return true;
}
}
}
coloredNodes.put(node, Color.BLACK);
return false;
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class MonitorEventHandler method handleEvent.
/**
* @param event
* @param forward
* @param graph
*/
private void handleEvent(EventData event, boolean forward, Graph graph) {
// EventType type = event.getType();
String nodeID = event.getWorkflowNodeId();
Node node = graph.getNode(nodeID);
if (node != null) {
if (event.getStatus().equals(WorkflowNodeState.INVOKED.toString())) {
invokeNode(node);
// workflowStarted(graph, forward);
// workflowStatusUpdater.workflowStarted(event.getExperimentID());
} else if (event.getStatus().equals(WorkflowNodeState.COMPLETED.toString())) {
nodeFinished(node, true);
// workflowFinished(graph, forward);
// workflowStatusUpdater.workflowFinished(event.getExperimentID());
} else if (event.getStatus().equals(WorkflowNodeState.EXECUTING.toString())) {
nodeStarted(node, forward);
// workflowNodeStatusUpdater.workflowStarted(event.getExperimentID(), event.getNodeID());
} else {
// Ignore the rest.
}
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class DifferedInputHandler method onlyWaitingOnIncompleteDifferedInputNode.
public static boolean onlyWaitingOnIncompleteDifferedInputNode(Node node) {
List<DataPort> inputPorts = node.getInputPorts();
boolean atleadOneDifferedInputNodeIsIncomplete = false;
for (DataPort dataPort : inputPorts) {
Node fromNode = dataPort.getFromNode();
if (NodeController.isFinished(fromNode)) {
// no op
} else if (isDifferedInputNode(fromNode)) {
// not finished
if (!((DifferedInputNode) node).isConfigured()) {
// not configured differed node this is what we are looking for
// set the flag and ensure all the rest is finished
atleadOneDifferedInputNodeIsIncomplete = true;
}
} else {
// there is a not finished non differed input node
return false;
}
}
// if not finished nodes were found we wil not be here so
return atleadOneDifferedInputNodeIsIncomplete;
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class InstanceNode method edgeWasAdded.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
if (edge instanceof ControlEdge) {
Port toPort = edge.getToPort();
Node toNode = toPort.getNode();
/*
* check if there is already more than instance node connecting to destination node
*/
if (!(toNode instanceof InstanceNode)) {
for (Node node : toNode.getControlInPort().getFromNodes()) {
if ((node instanceof InstanceNode) && this != node) {
throw new GraphException("Cannot connect more than one instance node to another node.");
}
}
}
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class ResourceNode method edgeWasAdded.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
if (edge instanceof DataEdge) {
Port toPort = edge.getToPort();
Node toNode = toPort.getNode();
Port fromPort = edge.getFromPort();
Node fromNode = fromPort.getNode();
if (!(toNode instanceof ResourceNode && fromNode instanceof ResourceNode)) {
throw new GraphException("Cannot connect Resource Node to other type of nodes");
}
}
}
Aggregations