You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2012/01/27 20:00:20 UTC
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/
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<DataPort> outputPorts1 = node1.getOutputPorts();
- Node[] endForEachNodes = new Node[outputPorts1.size()];
- int j = 0;
+ 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[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<Node> finalEndForEachNodes = endForEachNodes;
Iterator<Node> endForEachNodeItr1 = node1.getOutputPort(0)
@@ -1042,20 +1040,10 @@ public class WorkflowInterpreter {
NodeState.EXECUTING.color);
List<DataPort> outputPorts = node1.getOutputPorts();
final AtomicInteger counter = new AtomicInteger();
- for (DataPort port : outputPorts) {
- Iterator<Node> 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<Node,Invoker> finalMap = this.invokerMap;
new Thread() {
@Override
@@ -1118,15 +1106,13 @@ public class WorkflowInterpreter {
// First node after foreach should end with EndForEachNode
List<DataPort> outputPorts1 = middleNode.getOutputPorts();
- Node[] endForEachNodes = new Node[outputPorts1.size()];
- int i = 0;
+ 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[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<Node> finalEndForEachNodes = endForEachNodes;
final Node foreachWSNode = middleNode;
final LinkedList<String> listOfValues = new LinkedList<String>();
@@ -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<DataPort> outputPorts = middleNode.getOutputPorts();
final AtomicInteger counter = new AtomicInteger();
- for (DataPort port : outputPorts) {
- Iterator<Node> 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<Node,Invoker> 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<String> listOfValues,
ForEachNode forEachNode, final Node middleNode,
- Node[] endForEachNodes,
+ List<Node> endForEachNodes,
Map<Node,Invoker> 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<Invoker> 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</" + arrayElementName + ">";
- for (Node endForEachNode : endForEachNodes) {
- if (!(endForEachNode instanceof OutputNode)) {
- ((SystemComponentInvoker)tempInvoker.get(endForEachNode)).addOutput(endForEachNode.getOutputPort(0).getName(),
- outputStr[i]);
- i++;
+ // 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.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("<temp>"
+ workflowInvoker.getOutput(outputName) + "</temp>");
@@ -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<repetition;j++){
+ for(int i=0;i<count;i++){
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ final long time = System.currentTimeMillis();
+ String s = xBayaClient.runWorkflow(UUID.randomUUID().toString(),nameValues);
+ String topic = "test";
+ System.out.println( (System.currentTimeMillis() - time));
+ Assert.assertEquals(topic, s);
+
+ completeCount.incrementAndGet();
+ } catch (Throwable e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }).start();
+ try {
+ Thread.sleep(1000 / count);
+ } catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }
+} catch (URISyntaxException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }}
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/XBayaClientTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/XBayaClientTest.java?rev=1236826&r1=1236825&r2=1236826&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/XBayaClientTest.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/XBayaClientTest.java Fri Jan 27 19:00:20 2012
@@ -36,21 +36,22 @@ import java.net.URISyntaxException;
public class XBayaClientTest {
@Test
public void testInvokeWorkflowString() {
-// try {
-/* ListenerManager manager = axis2ServiceStarter();
- XBayaClient xBayaClient = new XBayaClient("xbaya.properties");
- xBayaClient.loadWorkflowFromaFile("Mysimplemath.xwf");
- NameValue[] nameValues = xBayaClient.setInputs("xbaya.properties");
- String s = xBayaClient.runWorkflow("test",nameValues,"testuser");
+ try {
+// ListenerManager manager = axis2ServiceStarter();
+ XBayaClient xBayaClient = new XBayaClient("xbaya1.properties");
+ xBayaClient.loadWorkflowFromaFile("/Users/lahirugunathilake/localsimplemath.xwf");
+ NameValue[] nameValues = xBayaClient.setInputs("xbaya1.properties");
+ String s = xBayaClient.runWorkflow("test",nameValues,"admin");
org.junit.Assert.assertEquals("test",s);
- manager.stop();*/
-// } catch (URISyntaxException e) {
+
+// manager.stop();*/
+ } catch (URISyntaxException e) {
// TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (IOException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
// TODO Auto-generated catch block
-// e.printStackTrace();
-// }
+ e.printStackTrace();
+ }
}
private ListenerManager axis2ServiceStarter() throws AxisFault {
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/xbaya.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/xbaya.properties?rev=1236826&r1=1236825&r2=1236826&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/xbaya.properties (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/xbaya.properties Fri Jan 27 19:00:20 2012
@@ -1,12 +1,11 @@
-gfac.url=http://localhost:8080/axis2/services/GFacService?wsdl
-xregistry.url=https://gw39.quarry.iu.teragrid.org:19443/xregistry?wsdl
+gfac.url=http://156.56.179.104:8080/axis2/services/GFacService
myproxy.url=myproxy.teragrid.org
-messagebox.url=http://localhost:8080/axis2/services/MsgBoxService
-messagebroker.url=http://localhost:8080/axis2/services/EventingService
+messagebox.url=http://156.56.179.104:8080/axis2/services/MsgBoxService
+messagebroker.url=http://156.56.179.104:8080/axis2/services/EventingService
myproxy.username=ogce
-myproxy.password=testpassword
-xbaya.service.url=http://gw39.quarry.iu.teragrid.org:19080/axis2/services/XBayaService?wsdl
-jcr.url=http://localhost:8081/rmi
+myproxy.password=Jdas7wph
+xbaya.service.url=http://156.56.179.104:8080/axis2/services/WorkflowInterpretor?wsdl
+jcr.url=http://156.56.179.104:8081/rmi
jcr.username=admin
jcr.password=admin
-echo=Hello World
\ No newline at end of file
+echo=Hi
\ No newline at end of file