Search in sources :

Example 1 with WSComponent

use of org.apache.airavata.workflow.model.component.ws.WSComponent 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);
    }
}
Also used : DynamicComponent(org.apache.airavata.workflow.model.component.dynamic.DynamicComponent) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component) DynamicComponent(org.apache.airavata.workflow.model.component.dynamic.DynamicComponent) InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent)

Example 2 with WSComponent

use of org.apache.airavata.workflow.model.component.ws.WSComponent 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;
}
Also used : DynamicComponent(org.apache.airavata.workflow.model.component.dynamic.DynamicComponent) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) EdgeImpl(org.apache.airavata.workflow.model.graph.impl.EdgeImpl) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component) DynamicComponent(org.apache.airavata.workflow.model.component.dynamic.DynamicComponent) InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent) TerminateInstanceComponent(org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent)

Example 3 with WSComponent

use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.

the class LocalComponentRegistry method getComponents.

/**
 * @param file
 * @return The list of components defined in the specified file.
 * @throws ComponentException
 * @throws ComponentRegistryException
 */
public List<WSComponent> getComponents(File file) throws ComponentException, ComponentRegistryException {
    try {
        String compString = IOUtil.readFileToString(file);
        List<WSComponent> components = WSComponentFactory.createComponents(compString);
        return components;
    } catch (IOException e) {
        throw new ComponentRegistryException(e);
    }
}
Also used : WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) IOException(java.io.IOException) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException)

Example 4 with WSComponent

use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.

the class JythonScript method writeInvocation.

/**
 * @param node
 * @param thread
 * @param pw
 */
private void writeInvocation(WSNode node, boolean thread, PrintWriter pw) {
    String id = node.getID();
    String wsdlID = getWSDLID(node);
    WSComponent component = node.getComponent();
    QName portTypeQName = component.getPortTypeQName();
    String operation = component.getOperationName();
    pw.println(TAB + "# Invoke " + id + ".");
    pw.println(TAB + id + QNAME_SUFFIX + " = QName('" + portTypeQName.getNamespaceURI() + "', '" + portTypeQName.getLocalPart() + "')");
    pw.println(TAB + wsdlID + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + wsdlID + "')");
    pw.println(TAB + id + INVOKER_SUFFIX + " = " + "(" + id + QNAME_SUFFIX + ", " + wsdlID + ", '" + id + "',");
    pw.println(TAB + TAB + MESSAGE_BOX_URL_VARIABLE + ", " + GFAC_VARIABLE + ", " + NOTIFICATION_VARIABLE + ")");
    pw.println(TAB + "def " + INVOKE_METHOD + id + "():");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SETUP_METHOD + "()");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_OPERATION_METHOD + "('" + operation + "')");
    // Ports
    for (Port port : node.getInputPorts()) {
        String portName = port.getName();
        String value;
        Node fromNode = port.getFromNode();
        if (fromNode instanceof InputNode) {
            value = PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')";
        } else {
            Port fromPort = port.getFromPort();
            value = "" + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')";
            // This might try to remove a node that has been removed
            // already, but it's OK.
            this.executingNodes.remove(fromNode);
        }
        pw.println(TAB + TAB + portName + VALUE_SUFFIX + " = " + value);
        pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_INPUT_METHOD + "('" + portName + "', " + portName + VALUE_SUFFIX + ")");
    }
    pw.println(TAB + TAB + "print 'Invoking " + id + ".'");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + INVOKE_METHOD + "()");
    if (thread) {
        pw.println(TAB + "thread.start_new_thread(" + INVOKE_METHOD + id + ", ())");
    } else {
        pw.println(TAB + INVOKE_METHOD + id + "()");
    }
    pw.println();
    this.executingNodes.add(node);
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) QName(javax.xml.namespace.QName) 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) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent)

Example 5 with WSComponent

use of org.apache.airavata.workflow.model.component.ws.WSComponent in project airavata by apache.

the class BPELScript method getWSDLs.

/**
 * Returns the WSDLs of components in the workflow.
 *
 * @return The WSDLs of components.
 */
public Collection<XmlElement> getWSDLs() {
    Collection<XmlElement> wsdls = new ArrayList<XmlElement>();
    for (Node node : this.graph.getNodes()) {
        if (node instanceof WSNode) {
            WSNode wsNode = (WSNode) node;
            WSComponent component = wsNode.getComponent();
            wsdls.add(component.toXML());
        }
    }
    return wsdls;
}
Also used : WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) 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) ArrayList(java.util.ArrayList) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) XmlElement(org.xmlpull.infoset.XmlElement)

Aggregations

WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)13 Node (org.apache.airavata.workflow.model.graph.Node)6 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)6 Component (org.apache.airavata.workflow.model.component.Component)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)3 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)2 InstanceComponent (org.apache.airavata.workflow.model.component.amazon.InstanceComponent)2 TerminateInstanceComponent (org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent)2 DynamicComponent (org.apache.airavata.workflow.model.component.dynamic.DynamicComponent)2 WSComponentApplication (org.apache.airavata.workflow.model.component.ws.WSComponentApplication)2 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)2 Port (org.apache.airavata.workflow.model.graph.Port)2 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)2 EdgeImpl (org.apache.airavata.workflow.model.graph.impl.EdgeImpl)2 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)2 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)2 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)2