Search in sources :

Example 1 with EndDoWhileNode

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

the class EndDoWhileComponent method createNode.

/**
 * @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
 */
@Override
public Node createNode(Graph graph) {
    EndDoWhileNode node = new EndDoWhileNode(graph);
    node.setName(NAME);
    node.setComponent(this);
    // Creates a unique ID for the node. This has to be after setName().
    node.createID();
    createPorts(node);
    return node;
}
Also used : EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode)

Example 2 with EndDoWhileNode

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

the class WSGraphFactory method createNode.

/**
 * @see org.apache.airavata.workflow.model.graph.GraphFactory#createNode(org.xmlpull.infoset.XmlElement)
 */
public NodeImpl createNode(XmlElement nodeElement) throws GraphException {
    String type = nodeElement.attributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE);
    if (type == null) {
        // Old graphs don't have the namespace for the attribute.
        type = nodeElement.attributeValue(GraphSchema.NODE_TYPE_ATTRIBUTE);
    }
    NodeImpl node;
    if (GraphSchema.NODE_TYPE_WS.equals(type)) {
        node = new WSNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
        node = new StreamSourceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
        node = new WorkflowNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
        node = new InputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
        node = new OutputNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
        node = new ConstantNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
        node = new ForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
        node = new EndForEachNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
        node = new IfNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
        node = new EndifNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
        node = new DoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
        node = new EndDoWhileNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
        node = new MemoNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
        node = new ReceiveNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
        node = new BlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
        node = new EndBlockNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
        node = new InstanceNode(nodeElement);
    } else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
        node = new TerminateInstanceNode(nodeElement);
    } else {
        // Default is WsNode for backward compatibility.
        node = new WSNode(nodeElement);
    }
    return node;
}
Also used : BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ReceiveNode(org.apache.airavata.workflow.model.graph.system.ReceiveNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InstanceNode(org.apache.airavata.workflow.model.graph.amazon.InstanceNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) DoWhileNode(org.apache.airavata.workflow.model.graph.system.DoWhileNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) TerminateInstanceNode(org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 3 with EndDoWhileNode

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

the class DoWhileHandler method call.

/**
 * @see java.util.concurrent.Callable#call()
 */
@Override
public Boolean call() throws Exception {
    log.debug("Invoked Dowhile node");
    SystemComponentInvoker dowhileinvoker = new SystemComponentInvoker();
    // TODO check for multiple input case
    Object inputVal1 = InterpreterUtil.findInputFromPort(this.dowhilenode.getInputPort(0), this.invokerMap);
    dowhileinvoker.addOutput(this.dowhilenode.getOutputPort(0).getID(), inputVal1);
    this.invokerMap.put(this.dowhilenode, dowhileinvoker);
    this.finishedNodes.add(this.dowhilenode);
    ArrayList<Node> readyNodes = this.handleDowhile(this.waitingNode, this.finishedNodes);
    // invoking all the webservice components
    if (readyNodes.size() != 1) {
        throw new WorkflowRuntimeException("More than one dowhile execution not supported");
    }
    Node donode = readyNodes.get(0);
    this.interpreter.handleWSComponent(donode);
    log.debug("Invoked service " + donode.getName());
    List<DataPort> inputPorts = this.dowhilenode.getInputPorts();
    boolean runflag = true;
    while (runflag) {
        // while (true) {
        // if (NodeController.isRunning(donode) || NodeController.isWaiting(donode)) {
        // Thread.sleep(500);
        // log.debug("Service " + donode.getName() + " waiting");
        // } else if (NodeController.isFinished(donode)) {
        // log.debug("Service " + donode.getName() + " Finished");
        // List<DataPort> ports = this.dowhilenode.getOutputPorts();
        // for (int outputPortIndex = 0, inputPortIndex = 1; outputPortIndex < ports.size(); outputPortIndex++) {
        // Object inputValue = InterpreterUtil.findInputFromPort(this.dowhilenode.getInputPort(inputPortIndex), this.invokerMap);
        // dowhileinvoker.addOutput(this.dowhilenode.getOutputPort(outputPortIndex).getID(), inputValue);
        // }
        // break;
        // } else if (NodeController.isFailed(donode)) {
        // log.debug("Service " + donode.getName() + " Failed");
        // runflag = false;
        // dowhilenode.setState(NodeExecutionState.FAILED);
        // this.threadExecutor.shutdown();
        // return false;
        // } else if (donode.isBreak()) {
        // log.debug("Service " + donode.getName() + " set to break");
        // runflag = false;
        // break;
        // } else {
        // log.error("Service " + donode.getName() + " have unknow status");
        // throw new WorkFlowInterpreterException("Unknow status of the node");
        // }
        // }
        // this.invokerMap.put(this.dowhilenode, dowhileinvoker);
        log.debug("Going to evaluate do while expression for " + donode.getName());
        if (!evaluate(this.dowhilenode, inputPorts, this.invokerMap)) {
            log.debug("Expression evaluation is false so calling EndDoWhile");
            runflag = false;
        } else {
            if (readyNodes.size() != 1) {
                throw new WorkFlowInterpreterException("More than one dowhile execution not supported");
            }
            Node whileNode = readyNodes.get(0);
            log.debug("Expression evaluation is true so invoking service again " + whileNode.getName());
            this.interpreter.handleWSComponent(whileNode);
        }
    }
    // WS node should be done
    dowhilenode.setState(NodeExecutionState.FINISHED);
    EndDoWhileNode endDoWhileNode = this.dowhilenode.getEndDoWhileNode();
    // /////////////////////////////////////////////////////////
    // // Do WHile finished execution thus we can set the //////
    // //inputs to the EndDOWHile and resume the executions/////
    SystemComponentInvoker invoker = new SystemComponentInvoker();
    List<DataPort> inputports = endDoWhileNode.getInputPorts();
    for (int inputPortIndex = 0; inputPortIndex < inputports.size(); inputPortIndex++) {
        Object inputVal = dowhileinvoker.getOutput(inputports.get(inputPortIndex).getFromPort().getID());
        invoker.addOutput(endDoWhileNode.getOutputPort(inputPortIndex).getID(), inputVal);
    }
    this.invokerMap.put(endDoWhileNode, invoker);
    // TODO send mail once the iterations have converged
    endDoWhileNode.setState(NodeExecutionState.FINISHED);
    this.threadExecutor.shutdown();
    return true;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) 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) EndDoWhileNode(org.apache.airavata.workflow.model.graph.system.EndDoWhileNode) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

EndDoWhileNode (org.apache.airavata.workflow.model.graph.system.EndDoWhileNode)3 DoWhileNode (org.apache.airavata.workflow.model.graph.system.DoWhileNode)2 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 Node (org.apache.airavata.workflow.model.graph.Node)1 InstanceNode (org.apache.airavata.workflow.model.graph.amazon.InstanceNode)1 TerminateInstanceNode (org.apache.airavata.workflow.model.graph.amazon.TerminateInstanceNode)1 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)1 BlockNode (org.apache.airavata.workflow.model.graph.system.BlockNode)1 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)1 EndBlockNode (org.apache.airavata.workflow.model.graph.system.EndBlockNode)1 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)1 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)1 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)1 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)1 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)1 ReceiveNode (org.apache.airavata.workflow.model.graph.system.ReceiveNode)1 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)1