Search in sources :

Example 31 with Node

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;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 32 with Node

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.
        }
    }
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 33 with Node

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;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) DifferedInputNode(org.apache.airavata.workflow.model.graph.system.DifferedInputNode) Node(org.apache.airavata.workflow.model.graph.Node) DifferedInputNode(org.apache.airavata.workflow.model.graph.system.DifferedInputNode)

Example 34 with Node

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.");
                }
            }
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 35 with 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");
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node)

Aggregations

Node (org.apache.airavata.workflow.model.graph.Node)74 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)46 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)40 DataPort (org.apache.airavata.workflow.model.graph.DataPort)31 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)24 Port (org.apache.airavata.workflow.model.graph.Port)20 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)20 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)18 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)16 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)16 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)15 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)14 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)14 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)13 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)12 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)12 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)12 GraphException (org.apache.airavata.workflow.model.graph.GraphException)11 LinkedList (java.util.LinkedList)9 ArrayList (java.util.ArrayList)8