Search in sources :

Example 91 with DataPort

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

the class WorkflowInterpreter method setupNodeDetailsInput.

private void setupNodeDetailsInput(Node node, WorkflowNodeDetails nodeDetails) {
    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort dataPort : inputPorts) {
        Node fromNode = dataPort.getFromNode();
        String portInputValue = null;
        if (fromNode instanceof InputNode) {
            portInputValue = (String) ((InputNode) fromNode).getDefaultValue();
        } else if (fromNode instanceof WSNode) {
            Map<String, String> outputData = nodeOutputData.get(fromNode);
            portInputValue = outputData.get(dataPort.getName());
            if (portInputValue == null) {
                portInputValue = outputData.get(dataPort.getEdge(0).getFromPort().getName());
            }
        }
        // 123456789
        InputDataObjectType elem = new InputDataObjectType();
        elem.setName(dataPort.getName());
        elem.setValue(portInputValue);
        if (dataPort instanceof WSPort) {
            WSPort port = (WSPort) dataPort;
            elem.setInputOrder(port.getComponentPort().getInputOrder());
            elem.setApplicationArgument((port.getComponentPort().getApplicationArgument() != null ? port.getComponentPort().getApplicationArgument() : ""));
            elem.setType(port.getType());
        }
        nodeDetails.addToNodeInputs(elem);
    }
    try {
        getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
    } catch (RegistryException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) 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) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 92 with DataPort

use of org.apache.airavata.workflow.model.graph.DataPort 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 93 with DataPort

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

the class WorkflowInterpreter method handleSubWorkComponent.

private void handleSubWorkComponent(Node node) throws WorkflowException {
    // TODO we will not support this in 0.13
    notifyViaInteractor(WorkflowExecutionMessage.OPEN_SUBWORKFLOW, node);
    // setting the inputs
    Workflow subWorkflow = ((SubWorkflowNode) node).getWorkflow();
    ArrayList<Node> subWorkflowInputNodes = getInputNodes(subWorkflow);
    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort port : inputPorts) {
        Object inputVal = InterpreterUtil.findInputFromPort(port, this.invokerMap);
        if (null == inputVal) {
            throw new WorkFlowInterpreterException("Unable to find inputs for the subworkflow node node:" + node.getID());
        }
        for (Iterator<Node> iterator = subWorkflowInputNodes.iterator(); iterator.hasNext(); ) {
            InputNode inputNode = (InputNode) iterator.next();
            if (inputNode.getName().equals(port.getName())) {
                inputNode.setDefaultValue(inputVal);
            }
        }
    }
    for (Iterator<Node> iterator = subWorkflowInputNodes.iterator(); iterator.hasNext(); ) {
        InputNode inputNode = (InputNode) iterator.next();
        if (inputNode.getDefaultValue() == null) {
            throw new WorkFlowInterpreterException("Input not set for  :" + inputNode.getID());
        }
    }
    try {
        WorkflowInterpreter subworkflowInterpreter = (WorkflowInterpreter) getInputViaInteractor(WorkflowExecutionMessage.INPUT_WORKFLOWINTERPRETER_FOR_WORKFLOW, subWorkflow);
        subworkflowInterpreter.scheduleDynamically();
    } catch (Exception e) {
        throw new WorkflowException(e);
    }
}
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) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XPathExpressionException(javax.xml.xpath.XPathExpressionException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) DataPort(org.apache.airavata.workflow.model.graph.DataPort) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)

Example 94 with DataPort

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

the class WorkflowInterpreter method taskOutputChanged.

@Subscribe
public void taskOutputChanged(TaskOutputChangeEvent taskOutputEvent) {
    String taskId = taskOutputEvent.getTaskIdentity().getTaskId();
    if (isTaskAwaiting(taskId)) {
        ProcessState state = ProcessState.COMPLETED;
        Node node = getAwaitingNodeForTask(taskId);
        List<OutputDataObjectType> applicationOutputs = taskOutputEvent.getOutput();
        Map<String, String> outputData = new HashMap<String, String>();
        for (OutputDataObjectType outputObj : applicationOutputs) {
            List<DataPort> outputPorts = node.getOutputPorts();
            for (DataPort dataPort : outputPorts) {
                if (dataPort.getName().equals(outputObj.getName())) {
                    outputData.put(outputObj.getName(), outputObj.getValue());
                }
            }
        }
        nodeOutputData.put(node, outputData);
        setupNodeDetailsOutput(node);
        node.setState(NodeExecutionState.FINISHED);
        try {
            publishNodeStatusChange(WorkflowNodeState.COMPLETED, node.getID(), experiment.getExperimentID());
            updateWorkflowNodeStatus(nodeInstanceList.get(node), state);
        } catch (RegistryException e) {
            log.error(e.getMessage(), e);
        } catch (AiravataException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : ProcessState(org.apache.airavata.model.status.ProcessState) DataPort(org.apache.airavata.workflow.model.graph.DataPort) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) 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) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) Subscribe(com.google.common.eventbus.Subscribe)

Example 95 with DataPort

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

the class WorkflowInterpreter method setupNodeDetailsOutput.

private void setupNodeDetailsOutput(Node node) {
    WorkflowNodeDetails nodeDetails = nodeInstanceList.get(node);
    List<DataPort> outputPorts = node.getOutputPorts();
    Map<String, String> outputData = nodeOutputData.get(node);
    for (DataPort dataPort : outputPorts) {
        String portInputValue = outputData.get(dataPort.getName());
        OutputDataObjectType elem = new OutputDataObjectType();
        elem.setName(dataPort.getName());
        elem.setValue(portInputValue);
        nodeDetails.addToNodeOutputs(elem);
    }
    try {
        getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
    } catch (RegistryException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

DataPort (org.apache.airavata.workflow.model.graph.DataPort)100 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)39 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)26 Node (org.apache.airavata.workflow.model.graph.Node)26 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)20 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)16 GraphException (org.apache.airavata.workflow.model.graph.GraphException)15 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)13 DataType (org.apache.airavata.model.application.io.DataType)12 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)12 Port (org.apache.airavata.workflow.model.graph.Port)11 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)10 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)9 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)8 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)8 LinkedList (java.util.LinkedList)7 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)7 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)6 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)6