Search in sources :

Example 56 with Node

use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.

the class JythonScript method writeOutput.

private void writeOutput(OutputNode node, PrintWriter pw) throws GraphException {
    String id = node.getID();
    Port port = node.getPort();
    Node fromNode = port.getFromNode();
    if (fromNode == null) {
        throw new GraphException("Output parameter has to be connected to some node.");
    }
    Port fromPort = port.getFromPort();
    if (fromNode instanceof InputNode) {
        // The OutputNode is directly connected to an InputNode.
        pw.println(TAB + id + VALUE_SUFFIX + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')");
    } else {
        pw.println(TAB + "# Wait output " + id);
        pw.println(TAB + id + VALUE_SUFFIX + " = " + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')");
    }
    pw.println(TAB + "print '" + id + " = ', " + id + VALUE_SUFFIX);
    // This might try to remove a node that has been removed
    // already, but it's OK.
    this.executingNodes.remove(fromNode);
    pw.println();
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Port(org.apache.airavata.workflow.model.graph.Port) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 57 with Node

use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.

the class JythonScript method writeWaitAll.

/**
 * @param pw
 */
private void writeWaitAll(PrintWriter pw) {
    pw.println(TAB + "# Wait all executing services.");
    for (Node node : this.executingNodes) {
        writeWait(node, pw);
    }
    pw.println();
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 58 with Node

use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.

the class JythonScript method writeInvocations.

/**
 * @param pw
 * @throws GraphException
 */
private void writeInvocations(PrintWriter pw) throws GraphException {
    Collection<Node> nextNodes = getNextNodes();
    while (nextNodes.size() > 0) {
        // If there are more than one nodes to invoke, they can run
        // concurrently using threads.
        boolean thread = (nextNodes.size() > 1);
        for (Node node : nextNodes) {
            if (node instanceof WSNode) {
                WSNode wsNode = (WSNode) node;
                writeInvocation(wsNode, thread, pw);
            } else {
            // TODO conditions, loops might come here.
            }
            this.notYetInvokedNodes.remove(node);
        }
        nextNodes = getNextNodes();
    }
}
Also used : WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 59 with Node

use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.

the class WorkflowModifier method createDifference.

/**
 * @return The workflow that needs to be executed.
 * @throws GraphException
 * @throws MonitorException
 */
public Workflow createDifference() throws GraphException, MonitorException {
    WSGraph originalGraph = this.modifiedWorkflow.getGraph();
    Workflow workflow = this.modifiedWorkflow.clone();
    String name = workflow.getName();
    name += " (diff)";
    workflow.setName(name);
    WSGraph graph = workflow.getGraph();
    // Remove the finished node.
    removeFinishedNodes(originalGraph, graph);
    Set<WSPort> originalFromPorts = getFinalOutputPorts(originalGraph, graph);
    // Create input nodes for unconnected input ports.
    createInputNodes(graph, originalFromPorts);
    // Set default values.
    for (WSPort originalFromPort : originalFromPorts) {
        // TODO handle the case that node is not WSNode.
        Node originalFromNode = originalFromPort.getNode();
        String fromNodeID = originalFromNode.getID();
        String output;
        if (originalFromNode instanceof InputNode) {
            // notification that includes the input of the workflow.
            output = getWorkflowInput(fromNodeID);
        } else if (originalFromNode instanceof WSNode) {
            // Retrieve input value from notification.
            WSComponent component = ((WSNode) originalFromNode).getComponent();
            String messageName = component.getOutputTypeName();
            String parameterName = originalFromPort.getComponentPort().getName();
            output = getOutput(fromNodeID, messageName, parameterName);
        } else {
            // This should not happen.
            throw new WorkflowRuntimeException(originalFromNode.getClass().getName());
        }
        Port originalToPort = originalFromPort.getToPorts().get(0);
        PortImpl toPort = graph.getPort(originalToPort.getID());
        InputNode inputNode = (InputNode) toPort.getFromNode();
        inputNode.setDefaultValue(output);
    }
    return workflow;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl)

Example 60 with Node

use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.

the class WorkflowHarvester method cleanLeftOverInputNodes.

/**
 * @param clone
 */
private void cleanLeftOverInputNodes(Workflow clone) {
    List<NodeImpl> nodes = clone.getGraph().getNodes();
    LinkedList<Node> removeList = new LinkedList<Node>();
    for (Node nodeImpl : nodes) {
        if (nodeImpl instanceof InputNode) {
            if (nodeImpl.getOutputPort(0).getToNodes().size() == 0) {
                removeList.add(nodeImpl);
            }
        }
    }
    for (Node node : removeList) {
        try {
            clone.removeNode(node);
        } catch (GraphException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) LinkedList(java.util.LinkedList)

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