Return-Path: X-Original-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3706992D for ; Fri, 27 Jan 2012 19:00:48 +0000 (UTC) Received: (qmail 98838 invoked by uid 500); 27 Jan 2012 19:00:48 -0000 Delivered-To: apmail-incubator-airavata-commits-archive@incubator.apache.org Received: (qmail 98787 invoked by uid 500); 27 Jan 2012 19:00:48 -0000 Mailing-List: contact airavata-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: airavata-dev@incubator.apache.org Delivered-To: mailing list airavata-commits@incubator.apache.org Received: (qmail 98777 invoked by uid 99); 27 Jan 2012 19:00:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 19:00:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 19:00:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2F2552388860; Fri, 27 Jan 2012 19:00:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1236826 - in /incubator/airavata/trunk/modules/xbaya-gui/src: main/java/org/apache/airavata/xbaya/interpretor/ main/java/org/apache/airavata/xbaya/util/ test/java/org/apache/airavata/xbaya/interpreter/ test/resources/ Date: Fri, 27 Jan 2012 19:00:20 -0000 To: airavata-commits@incubator.apache.org From: lahiru@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120127190021.2F2552388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lahiru Date: Fri Jan 27 19:00:20 2012 New Revision: 1236826 URL: http://svn.apache.org/viewvc?rev=1236826&view=rev Log: Fixing issues with multiple EndforEach Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowPerfTest.java Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/XBayaClientTest.java incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/xbaya.properties Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java?rev=1236826&r1=1236825&r2=1236826&view=diff ============================================================================== --- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java (original) +++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java Fri Jan 27 19:00:20 2012 @@ -163,7 +163,7 @@ public class WorkflowInterpreter { private PredicatedTaskRunner provenanceWriter; - private boolean runWithCrossProduct = true; + private boolean runWithCrossProduct = false; private boolean isoffline = false; @@ -570,6 +570,7 @@ public class WorkflowInterpreter { } node.getGUI().setBodyColor(NodeState.FINISHED.color); } + System.out.println("Looping"); } this.notifier.sendingPartialResults(outputValues.toArray(), outputKeywords.toArray(new String[outputKeywords.size()])); @@ -1007,16 +1008,13 @@ public class WorkflowInterpreter { final WSNode node1 = (WSNode) wsNodes.get(i); SystemComponentInvoker systemInvoker = null; List outputPorts1 = node1.getOutputPorts(); - Node[] endForEachNodes = new Node[outputPorts1.size()]; - int j = 0; + List endForEachNodes = new ArrayList(); for (DataPort port : outputPorts1) { Iterator endForEachNodeItr1 = port.getToNodes().iterator(); while (endForEachNodeItr1.hasNext()) { Node node2 = endForEachNodeItr1.next(); if (node2 instanceof EndForEachNode) { - endForEachNodes[j] = (EndForEachNode) node2; - this.invokerMap.put(endForEachNodes[j], systemInvoker); - j++; + endForEachNodes.add(node2); } else if (node2 instanceof OutputNode) { // intentionally left noop } else { @@ -1026,7 +1024,7 @@ public class WorkflowInterpreter { } } - final Node[] finalEndForEachNodes = endForEachNodes; + final List finalEndForEachNodes = endForEachNodes; Iterator endForEachNodeItr1 = node1.getOutputPort(0) @@ -1042,20 +1040,10 @@ public class WorkflowInterpreter { NodeState.EXECUTING.color); List outputPorts = node1.getOutputPorts(); final AtomicInteger counter = new AtomicInteger(); - for (DataPort port : outputPorts) { - Iterator endForEachNodeItr = port - .getToNodes().iterator(); - while (endForEachNodeItr.hasNext()) { - systemInvoker = new SystemComponentInvoker(); - Object tempNode = endForEachNodeItr.next(); - if (tempNode instanceof EndForEachNode) { - endForEachNode = (EndForEachNode) tempNode; - endForEachNode.getGUI().setBodyColor( - NodeState.EXECUTING.color); - } - final Node tempendForEachNode = node2; - this.invokerMap.put(node2, systemInvoker); - }} + for (Node endFor : endForEachNodes) { + systemInvoker = new SystemComponentInvoker(); + this.invokerMap.put(endFor, systemInvoker); + } final Map finalMap = this.invokerMap; new Thread() { @Override @@ -1118,15 +1106,13 @@ public class WorkflowInterpreter { // First node after foreach should end with EndForEachNode List outputPorts1 = middleNode.getOutputPorts(); - Node[] endForEachNodes = new Node[outputPorts1.size()]; - int i = 0; + List endForEachNodes = new ArrayList(); for(DataPort port:outputPorts1){ Iterator endForEachNodeItr1 = port.getToNodes().iterator(); while (endForEachNodeItr1.hasNext()) { Node node2 = endForEachNodeItr1.next(); if (node2 instanceof EndForEachNode) { - endForEachNodes[i] = (EndForEachNode) node2; - i++; + endForEachNodes.add(node2); } else if (node2 instanceof OutputNode) { // intentionally left noop } else { @@ -1136,7 +1122,7 @@ public class WorkflowInterpreter { } } - final Node[] finalEndForEachNodes = endForEachNodes; + final List finalEndForEachNodes = endForEachNodes; final Node foreachWSNode = middleNode; final LinkedList listOfValues = new LinkedList(); @@ -1148,7 +1134,7 @@ public class WorkflowInterpreter { this.invokerMap); int parallelRuns = createInputValues(listOfValues, inputNumbers) - .size(); + .size() * outputPorts1.size(); if (listOfValues.size() > 0) { forEachNode.getGUI() @@ -1157,20 +1143,11 @@ public class WorkflowInterpreter { NodeState.EXECUTING.color); List outputPorts = middleNode.getOutputPorts(); final AtomicInteger counter = new AtomicInteger(); - for (DataPort port : outputPorts) { - Iterator endForEachNodeItr = port.getToNodes() - .iterator(); - while (endForEachNodeItr.hasNext()) { - Object tempNode = endForEachNodeItr.next(); - if (tempNode instanceof EndForEachNode) { - endForEachNode = (EndForEachNode) tempNode; - endForEachNode.getGUI().setBodyColor( - NodeState.EXECUTING.color); - final EndForEachNode tempendForEachNode = endForEachNode; - final SystemComponentInvoker systemInvoker = new SystemComponentInvoker(); - this.invokerMap.put(endForEachNode, - systemInvoker); - }} + for(Node endFor:endForEachNodes){ + final SystemComponentInvoker systemInvoker = new SystemComponentInvoker(); + this.invokerMap.put(endFor, + systemInvoker); + } final Map finalInvokerMap = this.invokerMap; new Thread() { @@ -1189,7 +1166,6 @@ public class WorkflowInterpreter { } }.start(); - } while (counter.intValue() < parallelRuns) { try { Thread.sleep(100); @@ -1376,7 +1352,7 @@ public class WorkflowInterpreter { private void runInThread(final LinkedList listOfValues, ForEachNode forEachNode, final Node middleNode, - Node[] endForEachNodes, + List endForEachNodes, Map tempInvoker, AtomicInteger counter, final Integer[] inputNumber) throws XBayaException { @@ -1453,17 +1429,19 @@ public class WorkflowInterpreter { // String arrayElementName = foreachWSNode.getOperationName() + // "ArrayResponse"; // String outputStr = "<" + arrayElementName + ">"; - String[] outputStr = new String[endForEachNodes.length]; + //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(Node endForEachNode:endForEachNodes){ + for(DataPort port:middleNode.getOutputPorts()){ String outputString = ""; for (Iterator iterator = invokerList.iterator(); iterator .hasNext(); ) { Invoker workflowInvoker = iterator.next(); // / - Object output = workflowInvoker.getOutput(endForEachNode - .getInputPort(0).getFromPort().getName()); + 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(); @@ -1478,13 +1456,19 @@ public class WorkflowInterpreter { i++; } i=0; - // outputStr += "\n"; - for (Node endForEachNode : endForEachNodes) { - if (!(endForEachNode instanceof OutputNode)) { - ((SystemComponentInvoker)tempInvoker.get(endForEachNode)).addOutput(endForEachNode.getOutputPort(0).getName(), - outputStr[i]); - i++; + // outputStr += "\n"; + 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.getGUI().setBodyColor(NodeState.FINISHED.color); } Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java?rev=1236826&r1=1236825&r2=1236826&view=diff ============================================================================== --- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java (original) +++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Fri Jan 27 19:00:20 2012 @@ -141,6 +141,7 @@ public class WorkflowInterpretorSkeleton try { conf = getConfiguration(configurations); conf.setTopic(topic); + conf.setRunWithCrossProduct(true); } catch (URISyntaxException e1) { throw new XBayaRuntimeException(e1); } Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java?rev=1236826&r1=1236825&r2=1236826&view=diff ============================================================================== --- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java (original) +++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java Fri Jan 27 19:00:20 2012 @@ -110,8 +110,8 @@ public class InterpreterUtil { } } } else if (workflowInvoker instanceof SystemComponentInvoker) { - String outputName = forEachInputNode.getOutputPort(0) - .getName(); + int index = forEachInputNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort()); + String outputName = ((SystemDataPort)forEachInputNode.getInputPort(index)).getWSComponentPort().getName(); returnValForProvenance = workflowInvoker .getOutput(outputName); XmlElement msgElmt = XmlConstants.BUILDER @@ -157,7 +157,7 @@ public class InterpreterUtil { } else if (fromNode instanceof EndForEachNode) { outputVal = ""; Invoker workflowInvoker = invokerMap.get(fromNode); - String outputName = fromNode.getOutputPort(0).getName(); + String outputName = ((SystemDataPort) inputPort).getWSComponentPort().getName(); XmlElement msgElmt = XmlConstants.BUILDER .parseFragmentFromString("" + workflowInvoker.getOutput(outputName) + ""); @@ -165,10 +165,13 @@ public class InterpreterUtil { while (valItr.hasNext()) { Object object2 = valItr.next(); if (object2 instanceof XmlElement) { + + if(((XmlElement) object2).children().iterator().hasNext()){ outputVal = outputVal + "," + ((XmlElement) object2).children().iterator() .next().toString(); + } } } @@ -282,9 +285,8 @@ public class InterpreterUtil { } inputNumbers[inputPorts.indexOf(forEachInputPort)] = index; } else if (workflowInvoker instanceof SystemComponentInvoker) { - - String outputName = forEachInputNode.getOutputPort(0) - .getName(); + int portIndex = forEachInputNode.getOutputPorts().indexOf(forEachInputPort.getEdge(0).getFromPort()); + String outputName = ((SystemDataPort)forEachInputNode.getInputPort(portIndex)).getWSComponentPort().getName(); returnValForProvenance = workflowInvoker .getOutput(outputName); XmlElement msgElmt = XmlConstants.BUILDER Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowPerfTest.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowPerfTest.java?rev=1236826&view=auto ============================================================================== --- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowPerfTest.java (added) +++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowPerfTest.java Fri Jan 27 19:00:20 2012 @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.xbaya.interpreter; + +import org.apache.airavata.common.registry.api.impl.JCRRegistry; +import org.apache.airavata.xbaya.clients.XBayaClient; +import org.apache.airavata.xbaya.interpretor.NameValue; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; + +public class WorkflowPerfTest { + + @Test + public void testInvokeWorkflowString(){ + final AtomicInteger completeCount = new AtomicInteger(0); + int count = 1; + int repetition = 1; + try { + final XBayaClient xBayaClient = new XBayaClient("xbaya.properties"); + xBayaClient.loadWorkflowFromaFile("ranger-echo.xwf"); + final NameValue[] nameValues = xBayaClient.setInputs("xbaya.properties"); + for(int j=0;j