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

Examples of org.apache.airavata.workflow.model.graph.ws.WSNode


        // We do this because invokers cannot be cached because the puretls expires
        if (invoker != null) {
            this.invokerMap.remove(invoker);
        }

        final WSNode wsNode = (WSNode) node;
        String wsdlLocation = InterpreterUtil.getEPR(wsNode);
        final String gfacURLString = this.getConfig().getConfiguration().getGFacURL().toString();
        if (null == wsdlLocation) {

            /* If there is a instance control component connects to this
             * component send information in soap header */
            for (Node n : wsNode.getControlInPort().getFromNodes()) {
                if (n instanceof InstanceNode) {
                    AmazonSecurityContext amazonSecurityContext;
                    final String awsAccessKeyId = config.getAwsAccessKey();
                    final String awsSecretKey = config.getAwsSecretKey();
                    final String username = ((InstanceNode) n).getUsername();

                    if (((InstanceNode) n).isStartNewInstance()) {
                        final String amiId = ((InstanceNode) n).getIdAsValue();
                        final String instanceType = ((InstanceNode) n).getInstanceType();

                        amazonSecurityContext =
                                new AmazonSecurityContext(username, awsAccessKeyId, awsSecretKey, amiId, instanceType);
                    } else {
                        final String instanceId = ((InstanceNode) n).getIdAsValue();
                        amazonSecurityContext =
                                new AmazonSecurityContext(username, awsAccessKeyId, awsSecretKey, instanceId);
                    }

                    this.config.getConfiguration().setAmazonSecurityContext(amazonSecurityContext);
                }
            }

            if ((this.config.isGfacEmbeddedMode()) || (config.getAwsAccessKey() != null)) {
                invoker = new EmbeddedGFacInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
                        this.config.getMessageBoxURL().toASCIIString(), this.config.getMessageBrokerURL().toASCIIString(), this.config.getNotifier(),
                        this.config.getTopic(), this.config.getAiravataAPI(), portTypeQName.getLocalPart(), this.config.getConfiguration());
            } else {
                invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
                        this.config.getMessageBoxURL().toASCIIString(), gfacURLString, this.config.getNotifier());
            }

        } else {
      if (wsdlLocation.endsWith("/")) {
View Full Code Here


            wsNodes.add(subWorkflowNode);
          }
        }

        for (int i = 0; i < wsNodes.size(); i++) {
          final WSNode node1 = (WSNode) wsNodes.get(i);
          SystemComponentInvoker systemInvoker = null;
          List<DataPort> outputPorts1 = node1.getOutputPorts();
          List<Node> endForEachNodes = new ArrayList<Node>();
          for (DataPort port : outputPorts1) {
            Iterator<Node> endForEachNodeItr1 = port.getToNodes().iterator();
            while (endForEachNodeItr1.hasNext()) {
              Node node2 = endForEachNodeItr1.next();
              if (node2 instanceof EndForEachNode) {
                endForEachNodes.add(node2);
              } else if (node2 instanceof OutputNode) {
                // intentionally left noop
              } else {
                throw new WorkFlowInterpreterException("Found More than one node inside foreach");
              }

            }
          }
          final List<Node> finalEndForEachNodes = endForEachNodes;

          Iterator<Node> endForEachNodeItr1 = node1.getOutputPort(0).getToNodes().iterator();
          while (endForEachNodeItr1.hasNext()) {
            Node node2 = endForEachNodeItr1.next();
            // Start reading input came for foreach node
            int parallelRuns = listOfValues.size() * node1.getOutputPorts().size();
            if (listOfValues.size() > 0) {
              forEachNode.setState(NodeExecutionState.EXECUTING);
              node1.setState(NodeExecutionState.EXECUTING);
              List<DataPort> outputPorts = node1.getOutputPorts();
              final AtomicInteger counter = new AtomicInteger();
              for (Node endFor : endForEachNodes) {
                systemInvoker = new SystemComponentInvoker();
                this.invokerMap.put(endFor, systemInvoker);
              }
              final Map<Node, Invoker> finalMap = this.invokerMap;
              new Thread() {
                @Override
                public void run() {
                  try {
                    runInThread(listOfValues, forEachNode, node1, finalEndForEachNodes, finalMap, counter, inputNumbers);
                  } catch (WorkflowException e) {

                    WorkflowInterpreter.this.config.getGUI().getErrorWindow().error(e);
                  }
                }

              }.start();

              while (counter.intValue() < parallelRuns) {
                try {
                  Thread.sleep(100);
                } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                }

              }
              if (!(node2 instanceof OutputNode)) {
                listOfValues.removeAll(listOfValues);
                String output = (String) systemInvoker.getOutput(node1.getOutputPort(0).getName());
                XmlElement xmlElement = XMLUtil.stringToXmlElement("<result>" + output + "</result>");
                Iterator iterator1 = xmlElement.children().iterator();
                while (iterator1.hasNext()) {
                  Object next1 = iterator1.next();
                  if (next1 instanceof XmlElement) {
View Full Code Here

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

    /**
     * @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
     */
    @Override
    public Node createNode(Graph graph) {
        return createNode(graph, new WSNode(graph));
    }
View Full Code Here

    // We do this because invokers cannot be cached because the puretls
    // expires
    if (invoker != null) {
      this.invokerMap.remove(invoker);
    }
    final WSNode wsNode = (WSNode) node;
    String wsdlLocation = InterpreterUtil.getEPR(wsNode);
    final String gfacURLString = this.getConfig().getConfiguration().getGFacURL().toString();
    if (null == wsdlLocation) {
      if (gfacURLString.startsWith("https")) {
        LeadContextHeader leadCtxHeader = null;
        try {
          leadCtxHeader = XBayaUtil.buildLeadContextHeader(this.getWorkflow(), this.getConfig().getConfiguration(), new MonitorConfiguration(this
              .getConfig().getConfiguration().getBrokerURL(), this.config.getTopic(), true, this.getConfig().getConfiguration()
              .getMessageBoxURL()), wsNode.getID(), null);
        } catch (URISyntaxException e) {
          throw new WorkflowException(e);
        }

        leadCtxHeader.setServiceId(node.getID());
        try {
          leadCtxHeader.setWorkflowId(new URI(this.getWorkflow().getName()));

          // We do this so that the wsdl resolver can is setup
          // wsdlresolver.getInstance is static so once this is
          // done
          // rest of the loading should work.

        } catch (URISyntaxException e) {
          throw new WorkflowRuntimeException(e);
        }

        /*
         * Resource Mapping Header
         */
        if (this.resourceMapping != null) {
          leadCtxHeader.setResourceMapping(this.resourceMapping);
        }

        /*
         * If there is a instance control component connects to this
         * component send information in soap header
         */
        for (Node n : wsNode.getControlInPort().getFromNodes()) {
          if (n instanceof InstanceNode) {
            // TODO make it as constant
            LeadResourceMapping x = new LeadResourceMapping("AMAZON");

            x.addAttribute("ACCESS_KEY", AmazonCredential.getInstance().getAwsAccessKeyId());
            x.addAttribute("SECRET_KEY", AmazonCredential.getInstance().getAwsSecretAccessKey());

            if (((InstanceNode) n).isStartNewInstance()) {
              x.addAttribute("AMI_ID", ((InstanceNode) n).getIdAsValue());
              x.addAttribute("INS_TYPE", ((InstanceNode) n).getInstanceType());
            } else {
              x.addAttribute("INS_ID", ((InstanceNode) n).getIdAsValue());
            }

            x.addAttribute("USERNAME", ((InstanceNode) n).getUsername());

            // set to leadHeader
            leadCtxHeader.setResourceMapping(x);
          }
        }

        invoker = new WorkflowInvokerWrapperForGFacInvoker(portTypeQName, gfacURLString, this.config.getMonitor().getConfiguration().getMessageBoxURL()
            .toString(), leadCtxHeader, this.config.getNotifier().createServiceNotificationSender(node.getID()));

      } else {
        if (this.config.isGfacEmbeddedMode()) {
          invoker = new EmbeddedGFacInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
              this.config.getMessageBoxURL().toASCIIString(), this.config.getMessageBrokerURL().toASCIIString(), this.config.getNotifier(),
              this.config.getTopic(), this.config.getAiravataAPI(), portTypeQName.getLocalPart(), this.config.getConfiguration());
        } else {
          invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
              this.config.getMessageBoxURL().toASCIIString(), gfacURLString, this.config.getNotifier());
        }

      }

View Full Code Here

            wsNodes.add(subWorkflowNode);
          }
        }

        for (int i = 0; i < wsNodes.size(); i++) {
          final WSNode node1 = (WSNode) wsNodes.get(i);
          SystemComponentInvoker systemInvoker = null;
          List<DataPort> outputPorts1 = node1.getOutputPorts();
          List<Node> endForEachNodes = new ArrayList<Node>();
          for (DataPort port : outputPorts1) {
            Iterator<Node> endForEachNodeItr1 = port.getToNodes().iterator();
            while (endForEachNodeItr1.hasNext()) {
              Node node2 = endForEachNodeItr1.next();
              if (node2 instanceof EndForEachNode) {
                endForEachNodes.add(node2);
              } else if (node2 instanceof OutputNode) {
                // intentionally left noop
              } else {
                throw new WorkFlowInterpreterException("Found More than one node inside foreach");
              }

            }
          }
          final List<Node> finalEndForEachNodes = endForEachNodes;

          Iterator<Node> endForEachNodeItr1 = node1.getOutputPort(0).getToNodes().iterator();
          while (endForEachNodeItr1.hasNext()) {
            Node node2 = endForEachNodeItr1.next();
            // Start reading input came for foreach node
            int parallelRuns = listOfValues.size() * node1.getOutputPorts().size();
            if (listOfValues.size() > 0) {
              forEachNode.setState(NodeExecutionState.EXECUTING);
              node1.setState(NodeExecutionState.EXECUTING);
              List<DataPort> outputPorts = node1.getOutputPorts();
              final AtomicInteger counter = new AtomicInteger();
              for (Node endFor : endForEachNodes) {
                systemInvoker = new SystemComponentInvoker();
                this.invokerMap.put(endFor, systemInvoker);
              }
              final Map<Node, Invoker> finalMap = this.invokerMap;
              new Thread() {
                @Override
                public void run() {
                  try {
                    runInThread(listOfValues, forEachNode, node1, finalEndForEachNodes, finalMap, counter, inputNumbers);
                  } catch (WorkflowException e) {

                    WorkflowInterpreter.this.config.getGUI().getErrorWindow().error(e);
                  }
                }

              }.start();

              while (counter.intValue() < parallelRuns) {
                try {
                  Thread.sleep(100);
                } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                }

              }
              if (!(node2 instanceof OutputNode)) {
                listOfValues.removeAll(listOfValues);
                String output = (String) systemInvoker.getOutput(node1.getOutputPort(0).getName());
                XmlElement xmlElement = XMLUtil.stringToXmlElement("<result>" + output + "</result>");
                Iterator iterator1 = xmlElement.children().iterator();
                while (iterator1.hasNext()) {
                  Object next1 = iterator1.next();
                  if (next1 instanceof XmlElement) {
View Full Code Here

    // We do this because invokers cannot be cached because the puretls
    // expires
    if (invoker != null) {
      this.invokerMap.remove(invoker);
    }
    final WSNode wsNode = (WSNode) node;
    String wsdlLocation = InterpreterUtil.getEPR(wsNode);
    final String gfacURLString = this.getConfig().getConfiguration().getGFacURL().toString();
    if (null == wsdlLocation) {
      if (gfacURLString.startsWith("https")) {
        LeadContextHeader leadCtxHeader = null;
        try {
          leadCtxHeader = XBayaUtil.buildLeadContextHeader(this.getWorkflow(), this.getConfig().getConfiguration(), new MonitorConfiguration(this
              .getConfig().getConfiguration().getBrokerURL(), this.config.getTopic(), true, this.getConfig().getConfiguration()
              .getMessageBoxURL()), wsNode.getID(), null);
        } catch (URISyntaxException e) {
          throw new WorkflowException(e);
        }

        leadCtxHeader.setServiceId(node.getID());
        try {
          leadCtxHeader.setWorkflowId(new URI(this.getWorkflow().getName()));

          // We do this so that the wsdl resolver can is setup
          // wsdlresolver.getInstance is static so once this is
          // done
          // rest of the loading should work.

        } catch (URISyntaxException e) {
          throw new WorkflowRuntimeException(e);
        }

        /*
         * Resource Mapping Header
         */
        if (this.resourceMapping != null) {
          leadCtxHeader.setResourceMapping(this.resourceMapping);
        }

        /*
         * If there is a instance control component connects to this
         * component send information in soap header
         */
        for (Node n : wsNode.getControlInPort().getFromNodes()) {
          if (n instanceof InstanceNode) {
            // TODO make it as constant
            LeadResourceMapping x = new LeadResourceMapping("AMAZON");

            x.addAttribute("ACCESS_KEY", AmazonCredential.getInstance().getAwsAccessKeyId());
            x.addAttribute("SECRET_KEY", AmazonCredential.getInstance().getAwsSecretAccessKey());

            if (((InstanceNode) n).isStartNewInstance()) {
              x.addAttribute("AMI_ID", ((InstanceNode) n).getIdAsValue());
              x.addAttribute("INS_TYPE", ((InstanceNode) n).getInstanceType());
            } else {
              x.addAttribute("INS_ID", ((InstanceNode) n).getIdAsValue());
            }

            x.addAttribute("USERNAME", ((InstanceNode) n).getUsername());

            // set to leadHeader
            leadCtxHeader.setResourceMapping(x);
          }
        }

        invoker = new WorkflowInvokerWrapperForGFacInvoker(portTypeQName, gfacURLString, this.config.getMonitor().getConfiguration().getMessageBoxURL()
            .toString(), leadCtxHeader, this.config.getNotifier().createServiceNotificationSender(node.getID()));

      } else {
        if (this.config.isGfacEmbeddedMode()) {
          invoker = new EmbeddedGFacInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
              this.config.getMessageBoxURL().toASCIIString(), this.config.getMessageBrokerURL().toASCIIString(), this.config.getNotifier(),
              this.config.getTopic(), this.config.getRegistry(), portTypeQName.getLocalPart(), this.config.getConfiguration());
        } else {
          invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
              this.config.getMessageBoxURL().toASCIIString(), gfacURLString, this.config.getNotifier());
        }

      }

View Full Code Here

            wsNodes.add(subWorkflowNode);
          }
        }

        for (int i = 0; i < wsNodes.size(); i++) {
          final WSNode node1 = (WSNode) wsNodes.get(i);
          SystemComponentInvoker systemInvoker = null;
          List<DataPort> outputPorts1 = node1.getOutputPorts();
          List<Node> endForEachNodes = new ArrayList<Node>();
          for (DataPort port : outputPorts1) {
            Iterator<Node> endForEachNodeItr1 = port.getToNodes().iterator();
            while (endForEachNodeItr1.hasNext()) {
              Node node2 = endForEachNodeItr1.next();
              if (node2 instanceof EndForEachNode) {
                endForEachNodes.add(node2);
              } else if (node2 instanceof OutputNode) {
                // intentionally left noop
              } else {
                throw new WorkFlowInterpreterException("Found More than one node inside foreach");
              }

            }
          }
          final List<Node> finalEndForEachNodes = endForEachNodes;

          Iterator<Node> endForEachNodeItr1 = node1.getOutputPort(0).getToNodes().iterator();
          while (endForEachNodeItr1.hasNext()) {
            Node node2 = endForEachNodeItr1.next();
            // Start reading input came for foreach node
            int parallelRuns = listOfValues.size() * node1.getOutputPorts().size();
            if (listOfValues.size() > 0) {
              NodeController.getGUI(forEachNode).setBodyColor(NodeState.EXECUTING.color);
              NodeController.getGUI(node1).setBodyColor(NodeState.EXECUTING.color);
              List<DataPort> outputPorts = node1.getOutputPorts();
              final AtomicInteger counter = new AtomicInteger();
              for (Node endFor : endForEachNodes) {
                systemInvoker = new SystemComponentInvoker();
                this.invokerMap.put(endFor, systemInvoker);
              }
              final Map<Node, Invoker> finalMap = this.invokerMap;
              new Thread() {
                @Override
                public void run() {
                  try {
                    runInThread(listOfValues, forEachNode, node1, finalEndForEachNodes, finalMap, counter, inputNumbers);
                  } catch (WorkflowException e) {

                    WorkflowInterpreter.this.config.getGUI().getErrorWindow().error(e);
                  }
                }

              }.start();

              while (counter.intValue() < parallelRuns) {
                try {
                  Thread.sleep(100);
                } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                }

              }
              if (!(node2 instanceof OutputNode)) {
                listOfValues.removeAll(listOfValues);
                String output = (String) systemInvoker.getOutput(node1.getOutputPort(0).getName());
                XmlElement xmlElement = XMLUtil.stringToXmlElement("<result>" + output + "</result>");
                Iterator iterator1 = xmlElement.children().iterator();
                while (iterator1.hasNext()) {
                  Object next1 = iterator1.next();
                  if (next1 instanceof XmlElement) {
View Full Code Here

            wsNodes.add(subWorkflowNode);
          }
        }

        for (int i = 0; i < wsNodes.size(); i++) {
          final WSNode node1 = (WSNode) wsNodes.get(i);
          SystemComponentInvoker systemInvoker = null;
          List<DataPort> outputPorts1 = node1.getOutputPorts();
          List<Node> endForEachNodes = new ArrayList<Node>();
          for (DataPort port : outputPorts1) {
            Iterator<Node> endForEachNodeItr1 = port.getToNodes().iterator();
            while (endForEachNodeItr1.hasNext()) {
              Node node2 = endForEachNodeItr1.next();
              if (node2 instanceof EndForEachNode) {
                endForEachNodes.add(node2);
              } else if (node2 instanceof OutputNode) {
                // intentionally left noop
              } else {
                throw new WorkFlowInterpreterException("Found More than one node inside foreach");
              }

            }
          }
          final List<Node> finalEndForEachNodes = endForEachNodes;

          Iterator<Node> endForEachNodeItr1 = node1.getOutputPort(0).getToNodes().iterator();
          while (endForEachNodeItr1.hasNext()) {
            Node node2 = endForEachNodeItr1.next();
            // Start reading input came for foreach node
            int parallelRuns = listOfValues.size() * node1.getOutputPorts().size();
            if (listOfValues.size() > 0) {
              forEachNode.setState(NodeExecutionState.EXECUTING);
              node1.setState(NodeExecutionState.EXECUTING);
              List<DataPort> outputPorts = node1.getOutputPorts();
              final AtomicInteger counter = new AtomicInteger();
              for (Node endFor : endForEachNodes) {
                systemInvoker = new SystemComponentInvoker();
                this.invokerMap.put(endFor, systemInvoker);
              }
              final Map<Node, Invoker> finalMap = this.invokerMap;
              new Thread() {
                @Override
                public void run() {
                  try {
                    runInThread(listOfValues, forEachNode, node1, finalEndForEachNodes, finalMap, counter, inputNumbers);
                  } catch (WorkflowException e) {

                    WorkflowInterpreter.this.config.getGUI().getErrorWindow().error(e);
                  }
                }

              }.start();

              while (counter.intValue() < parallelRuns) {
                try {
                  Thread.sleep(100);
                } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                }

              }
              if (!(node2 instanceof OutputNode)) {
                listOfValues.removeAll(listOfValues);
                String output = (String) systemInvoker.getOutput(node1.getOutputPort(0).getName());
                XmlElement xmlElement = XMLUtil.stringToXmlElement("<result>" + output + "</result>");
                Iterator iterator1 = xmlElement.children().iterator();
                while (iterator1.hasNext()) {
                  Object next1 = iterator1.next();
                  if (next1 instanceof XmlElement) {
View Full Code Here

        // We do this because invokers cannot be cached because the puretls expires
        if (invoker != null) {
            this.invokerMap.remove(invoker);
        }

        final WSNode wsNode = (WSNode) node;
        String wsdlLocation = InterpreterUtil.getEPR(wsNode);
        final String gfacURLString = this.getConfig().getConfiguration().getGFacURL().toString();
        if (null == wsdlLocation) {

            /* If there is a instance control component connects to this
             * component send information in soap header */
            for (Node n : wsNode.getControlInPort().getFromNodes()) {
                if (n instanceof InstanceNode) {
                    AmazonSecurityContext amazonSecurityContext;
                    final String awsAccessKeyId = config.getAwsAccessKey();
                    final String awsSecretKey = config.getAwsSecretKey();
                    final String username = ((InstanceNode) n).getUsername();

                    if (((InstanceNode) n).isStartNewInstance()) {
                        final String amiId = ((InstanceNode) n).getIdAsValue();
                        final String instanceType = ((InstanceNode) n).getInstanceType();

                        amazonSecurityContext =
                                new AmazonSecurityContext(username, awsAccessKeyId, awsSecretKey, amiId, instanceType);
                    } else {
                        final String instanceId = ((InstanceNode) n).getIdAsValue();
                        amazonSecurityContext =
                                new AmazonSecurityContext(username, awsAccessKeyId, awsSecretKey, instanceId);
                    }

                    this.config.getConfiguration().setAmazonSecurityContext(amazonSecurityContext);
                }
            }

            if ((this.config.isGfacEmbeddedMode()) || (config.getAwsAccessKey() != null)) {
                invoker = new EmbeddedGFacInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
                        this.config.getMessageBoxURL().toASCIIString(), this.config.getMessageBrokerURL().toASCIIString(), this.config.getNotifier(),
                        this.config.getTopic(), this.config.getAiravataAPI(), portTypeQName.getLocalPart(), this.config.getConfiguration());
            } else {
                invoker = new GenericInvoker(portTypeQName, WSDLUtil.wsdlDefinitions5ToWsdlDefintions3(wsNode.getComponent().getWSDL()), node.getID(),
                        this.config.getMessageBoxURL().toASCIIString(), gfacURLString, this.config.getNotifier());
            }

        } else {
      if (wsdlLocation.endsWith("/")) {
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.model.graph.ws.WSNode

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.