Package org.apache.airavata.workflow.model.graph

Examples of org.apache.airavata.workflow.model.graph.Node


    // When you are starting 1st time its getting input from 1st node and
    // 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.info("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.info("Service " + donode.getName() + " waiting");
        } else if (NodeController.isFinished(donode)) {
          log.info("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.info("Service " + donode.getName() + " Failed");
          runflag = false;
          NodeController.getGUI(dowhilenode).setBodyColor(NodeState.FAILED.color);
          this.threadExecutor.shutdown();
          return false;
        } else if (donode.isBreak()) {
          log.info("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.info("Going to evaluate do while expression for " + donode.getName());
      if (!evaluate(this.dowhilenode, inputPorts, this.invokerMap)) {
        log.info("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);
        // this.dowhilenode.getGUI().setBodyColor(NodeState.STARTING.color);
        log.info("Expression evaluation is true so invoking service again " + whileNode.getName());

        this.interpreter.handleWSComponent(whileNode);
      }
    }
    // WS node should be done
View Full Code Here


    }

    private void handleEvent(MonitorEvent event, boolean forward, Graph graph) {
        EventType type = event.getType();
        String nodeID = event.getNodeID();
        Node node = graph.getNode(nodeID);

        if (type == MonitorUtil.EventType.WORKFLOW_INVOKED) {
            workflowStarted(graph, forward);
        } else if (type == MonitorUtil.EventType.WORKFLOW_TERMINATED) {
            workflowFinished(graph, forward);
View Full Code Here

    private void finishPredecessorNodes(Node node) {
        for (Port inputPort : node.getInputPorts()) {
            for (Edge edge : inputPort.getEdges()) {
                Port fromPort = edge.getFromPort();
                if (!(fromPort instanceof EPRPort)) {
                    Node fromNode = fromPort.getNode();
                    finishNode(fromNode);
                    finishPredecessorNodes(fromNode);
                }
            }
        }
View Full Code Here

    /**
     * Creates unique node ID in the graph that this node belongs to.
     */
    public void createID() {
        String candidateID = StringUtil.convertToJavaIdentifier(this.name);
        Node node = this.graph.getNode(candidateID);
        while (node != null && node != this) {
            candidateID = StringUtil.incrementName(candidateID);
            node = this.graph.getNode(candidateID);
        }
        this.id = candidateID;
View Full Code Here

        }

      } else if (node instanceof EndForEachNode) {
        // here we save the inputs for the entire foreach block
        Node middleNode = node.getInputPort(0).getFromNode();
        String nodeID = middleNode.getComponent().getName();
        XmlElement nodeElement = elem.newElement("foreach");
        elem.addChild(nodeElement);
        nodeElement.addChild(nodeID);
        inputs = elem.newElement("inputs");
        elem.addChild(inputs);
        XmlConstants.BUILDER.serializeToString(elem);
        if (middleNode instanceof ForEachExecutableNode) {
          List<DataPort> portsToBeSaved = middleNode.getInputPorts();
          for (DataPort savePort : portsToBeSaved) {
            // we will save all the inputs
            // these are static inputs and
            // input to the foreach node
View Full Code Here

        // Input ports need to be connected.
        Collection<Port> inputPorts = GraphUtil.getPorts(this.graph, Port.Kind.DATA_IN);
        for (Port inputPort : inputPorts) {
            Collection<Port> fromPorts = inputPort.getFromPorts();
            if (fromPorts.size() == 0) {
                Node node = inputPort.getNode();
                String message = node.getID() + " has an unconnected input " + inputPort.getName();
                warnings.add(message);
            }
        }

        // Input nodes need to be connected.
View Full Code Here

        // 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);
View Full Code Here

    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
View Full Code Here

     * @return
     * @throws WorkflowException
     */
  public static Object findInputFromPort(DataPort inputPort, Map<Node, Invoker>  invokerMap) throws WorkflowException {
    Object outputVal = null;
    Node fromNode = inputPort.getFromNode();
    if (fromNode instanceof InputNode) {
      outputVal = ((InputNode) fromNode).getDefaultValue();
    } else if (fromNode instanceof ConstantNode) {
      outputVal = ((ConstantNode) fromNode).getValue();
    } else if (fromNode instanceof EndifNode) {
      Invoker fromInvoker = invokerMap.get(fromNode);
      outputVal = fromInvoker.getOutput(inputPort.getFromPort().getID());
    } else if (fromNode instanceof InstanceNode) {
      return ((InstanceNode) fromNode).getOutputInstanceId();
    } else if (fromNode instanceof EndForEachNode) {
      outputVal = "";
      Invoker workflowInvoker = invokerMap.get(fromNode);
      String outputName = fromNode.getOutputPort(0).getName();
      XmlElement msgElmt = XmlConstants.BUILDER
          .parseFragmentFromString("<temp>"
              + workflowInvoker.getOutput(outputName) + "</temp>");
      Iterator valItr = msgElmt.children().iterator();
      while (valItr.hasNext()) {
View Full Code Here

    Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
    if(toNodes.size() != 1){
      throw new WorkflowRuntimeException("ForEach output does not contain single out-edge");
    }
    Node middleNode = toNodes.iterator().next();
    List<DataPort> outputPorts = middleNode.getOutputPorts();
    for (DataPort dataPort : outputPorts) {
      if(dataPort.getToNodes().size() == 1){
        Node possibleEndForEachNode = dataPort.getToNodes().get(0);
        if(possibleEndForEachNode instanceof EndForEachNode){
          return possibleEndForEachNode;
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.model.graph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.