Search in sources :

Example 11 with WSComponent

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

the class Workflow method bindComponents.

/**
 * Binds WSNodes to components
 *
 * @throws ComponentException
 * @throws GraphException
 */
public void bindComponents() throws ComponentException, GraphException {
    // This map is to avoid creating multiple instances for the a component
    Map<WSComponentKey, WSComponent> components = new HashMap<WSComponentKey, WSComponent>();
    for (WSNode node : GraphUtil.getWSNodes(this.graph)) {
        String id = node.getWSDLID();
        logger.debug("id: " + id);
    // WsdlDefinitions wsdl = this.wsdlMap.get(id);
    // 
    // if (wsdl == null) {
    // // XXX This happens while loading a workflow that is created by
    // // the version 2.2.6_2 or below from GPEL.
    // // Need to look for wsdl manually.
    // // id should be look like
    // // {http://www.extreme.indiana.edu/math/}Adder
    // for (WsdlDefinitions w : this.wsdlMap.values()) {
    // QName name = WSDLUtil.getWSDLQName(w);
    // if (name.toString().equals(id)) {
    // wsdl = w;
    // break;
    // }
    // }
    // }
    // if (wsdl == null) {
    // continue;
    // }
    // try {
    // QName portType = node.getPortTypeQName();
    // if (portType == null) {
    // // XXX This happens while parsing xwf created by the version
    // // 2.2.6_1 or below.
    // portType = WSDLUtil.getFirstPortTypeQName(wsdl);
    // }
    // String operation = node.getOperationName();
    // if (operation == null) {
    // // XXX This happens while parsing xwf created by the version
    // // 2.2.6_1 or below.
    // operation = WSDLUtil.getFirstOperationName(wsdl, portType);
    // }
    // WSComponentKey key = new WSComponentKey(id, portType, operation);
    // 
    // WSComponent component = null;
    // if (components.containsKey(key)) {
    // component = components.get(key);
    // } else {
    // //FIXME
    // //                    component = WSComponentFactory.createComponent(wsdl, portType, operation);
    // components.put(key, component);
    // }
    // node.setComponent(component);
    // } catch (UtilsException e) {
    // logger.error(e.getMessage(), e);
    // }
    }
    this.graph.fixParameterNodes();
    GraphUtil.propagateTypes(this.graph);
}
Also used : WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) HashMap(java.util.HashMap) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) WSComponentKey(org.apache.airavata.workflow.model.component.ws.WSComponentKey)

Example 12 with WSComponent

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

the class WorkflowInterpreter method runInThread.

private void runInThread(final LinkedList<String> listOfValues, ForEachNode forEachNode, final Node middleNode, List<Node> endForEachNodes, Map<Node, Invoker> tempInvoker, AtomicInteger counter, final Integer[] inputNumber) throws WorkflowException, RegistryException, TException {
    final LinkedList<String> taskIdList = new LinkedList<String>();
    if (inputNumber.length > 1) {
        List<String> inputValues = createInputValues(listOfValues, inputNumber);
        for (final Iterator<String> iterator = inputValues.iterator(); iterator.hasNext(); ) {
            final String input = iterator.next();
            WSComponent wsComponent = (WSComponent) middleNode.getComponent();
            final String invoker2 = createInvokerForEachSingleWSNode(middleNode, wsComponent);
            taskIdList.add(invoker2);
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                log.error(e.getLocalizedMessage(), e);
            }
        }
    } else {
        String invoker = null;
        for (Iterator<String> iterator = listOfValues.iterator(); iterator.hasNext(); ) {
            String input = iterator.next();
            WSComponent wsComponent = (WSComponent) middleNode.getComponent();
            taskIdList.add(invoker);
            // find inputs
            List<DataPort> inputPorts = middleNode.getInputPorts();
            // for (DataPort port : inputPorts) {
            // Object inputVal = InterpreterUtil.findInputFromPort(port, this.invokerMap);
            // /*
            // * Handle ForEachNode
            // */
            // Node fromNode = port.getFromNode();
            // // if (fromNode instanceof ForEachNode) {
            // inputVal = WorkflowInputUtil.parseValue((WSComponentPort) port.getComponentPort(), input);
            // // }
            // 
            // if (null == inputVal) {
            // throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + middleNode.getID());
            // }
            // }
            invoker = createInvokerForEachSingleWSNode(middleNode, wsComponent);
        }
    }
    // String arrayElementName = foreachWSNode.getOperationName() +
    // "ArrayResponse";
    // String outputStr = "<" + arrayElementName + ">";
    // invokerMap size and endForEachNodes size can be difference
    // because we can create endForEachNode with n number of input/output
    // ports so always have to use
    // middleNode.getOutputPorts when iterate
    String[] outputStr = new String[middleNode.getOutputPorts().size()];
    int i = 0;
    for (DataPort port : middleNode.getOutputPorts()) {
        String outputString = "";
        // for (Iterator<Invoker> iterator = taskIdList.iterator(); iterator.hasNext();) {
        // Invoker workflowInvoker = iterator.next();
        // 
        // // /
        // Object output = workflowInvoker.getOutput(port.getName());
        // if (output instanceof org.xmlpull.v1.builder.XmlElement) {
        // org.xmlpull.v1.builder.XmlElement element = (org.xmlpull.v1.builder.XmlElement) ((org.xmlpull.v1.builder.XmlElement) output).children()
        // .next();
        // outputString += "\n" + XMLUtil.xmlElementToString(element);
        // } else {
        // outputString += "\n<value>" + output + "</value>";
        // }
        // counter.incrementAndGet();
        // }
        outputStr[i] = outputString;
        System.out.println(outputStr[i]);
        i++;
    }
    i = 0;
    // outputStr += "\n</" + arrayElementName + ">";
    int outputPortIndex = 0;
    for (DataPort port : middleNode.getOutputPorts()) {
        for (Node endForEachNode : endForEachNodes) {
            if (tempInvoker.get(endForEachNode) != null) {
                if (!(endForEachNode instanceof OutputNode)) {
                    ((SystemComponentInvoker) tempInvoker.get(endForEachNode)).addOutput(port.getName(), outputStr[i]);
                }
            }
            outputPortIndex++;
        }
        i++;
    }
    forEachNode.setState(NodeExecutionState.FINISHED);
}
Also used : 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) DataPort(org.apache.airavata.workflow.model.graph.DataPort)

Example 13 with WSComponent

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

the class DoWhileHandler method handleDowhile.

/**
 * To get only web service components attached to dowhile
 *
 * @param waitingNode
 * @return list
 */
private ArrayList<Node> handleDowhile(ArrayList<Node> waitingNode, ArrayList<Node> finishedNodes) {
    ArrayList<Node> list = new ArrayList<Node>();
    for (Node node : waitingNode) {
        Component component = node.getComponent();
        if (component instanceof WSComponent) {
            ControlPort control = node.getControlInPort();
            boolean controlDone = true;
            if (control != null) {
                for (EdgeImpl edge : control.getEdges()) {
                    controlDone = controlDone && (finishedNodes.contains(edge.getFromPort().getNode()) || ((ControlPort) edge.getFromPort()).isConditionMet());
                }
            }
            /*
				 * Check for input ports
				 */
            List<DataPort> inputPorts = node.getInputPorts();
            boolean inputsDone = true;
            for (DataPort dataPort : inputPorts) {
                inputsDone = inputsDone && finishedNodes.contains(dataPort.getFromNode());
            }
            if (inputsDone && controlDone) {
                list.add(node);
            }
        }
    }
    return list;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) Node(org.apache.airavata.workflow.model.graph.Node) DoWhileNode(org.apache.airavata.workflow.model.graph.system.DoWhileNode) ArrayList(java.util.ArrayList) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) EdgeImpl(org.apache.airavata.workflow.model.graph.impl.EdgeImpl) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component)

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