airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1350392 - in /incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya: interpretor/WorkflowInterpreter.java provenance/ProvenanceWrite.java
Date Thu, 14 Jun 2012 20:43:05 GMT
Author: lahiru
Date: Thu Jun 14 20:43:04 2012
New Revision: 1350392

URL: http://svn.apache.org/viewvc?rev=1350392&view=rev
Log:
fixing provneance smart rerun issues with forEach.

Modified:
    incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
    incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/ProvenanceWrite.java

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java?rev=1350392&r1=1350391&r2=1350392&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
(original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
Thu Jun 14 20:43:04 2012
@@ -70,6 +70,7 @@ import org.apache.airavata.xbaya.concurr
 import org.apache.airavata.xbaya.graph.ControlPort;
 import org.apache.airavata.xbaya.graph.DataPort;
 import org.apache.airavata.xbaya.graph.Node;
+import org.apache.airavata.xbaya.graph.Port;
 import org.apache.airavata.xbaya.graph.amazon.InstanceNode;
 import org.apache.airavata.xbaya.graph.dynamic.BasicTypeMapping;
 import org.apache.airavata.xbaya.graph.dynamic.DynamicNode;
@@ -472,24 +473,59 @@ public class WorkflowInterpreter {
             if(output != null){
             XmlElement result = XMLUtil.stringToXmlElement(output);
             SystemComponentInvoker invoker = new SystemComponentInvoker();
-				List<DataPort> outPorts = node.getOutputPorts();
-				for (DataPort dataPort : outPorts) {
-
-					Iterable itr = result.children();
-					for (Object outputElem : itr) {
-						if (outputElem instanceof XmlElement) {
-							if (((XmlElement) outputElem).getName().equals(
-									dataPort.getName())) {
-								invoker.addOutput(dataPort.getName(),
-										((XmlElement) outputElem).children()
-												.iterator().next());
-							}
-						}
-					}
-				}
+                if(node instanceof ForEachNode) {
+                    //todo only supports foreach node with single output ports at the middle
node, implement proper
+                    // provesioning support with foreach scenarios
+                    Node endForEachFor = InterpreterUtil.findEndForEachFor((ForEachNode)
node);
+                    List<DataPort> inputPorts1 = endForEachFor.getInputPorts();
+                    for(DataPort inputPort:inputPorts1){
+                        Port fromPort = inputPort.getFromPort();
+                                    invoker.addOutput(fromPort.getName(),
+                                            (((XmlElement) result.children().iterator().next()).children().iterator().next()));
+                        node.getGUI().setBodyColor(NodeState.FINISHED.color);
+                        Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
+                        for(Node middleNode:toNodes){
+                            middleNode.getGUI().setBodyColor(NodeState.FINISHED.color);
+                        }
+                        endForEachFor.getGUI().setBodyColor(NodeState.FINISHED.color);
+                        List<DataPort> outputPorts = endForEachFor.getOutputPorts();
+                        for(DataPort outport:outputPorts){
+                            List<Node> toNodes1 = outport.getToNodes();
+                            for(Node endNode:toNodes1){
+                                if(endNode instanceof OutputNode){
+                                    endNode.getGUI().setBodyColor(NodeState.FINISHED.color);
+                                }
+                            }
+                        }
 
-				this.invokerMap.put(node, invoker);
-				node.getGUI().setBodyColor(NodeState.FINISHED.color);
+                    }
+                }else{
+                    List<DataPort> outPorts = node.getOutputPorts();
+                    for (DataPort dataPort : outPorts) {
+                        Iterable itr = result.children();
+                        for (Object outputElem : itr) {
+                            if (outputElem instanceof XmlElement) {
+                                if (((XmlElement) outputElem).getName().equals(
+                                        dataPort.getName())) {
+                                    invoker.addOutput(dataPort.getName(),
+                                            ((XmlElement) outputElem).children()
+                                                    .iterator().next());
+                                }
+                            }
+                        }
+                    }
+                    node.getGUI().setBodyColor(NodeState.FINISHED.color);
+                }
+                List<DataPort> outputPorts = node.getOutputPorts();
+                for(DataPort outputPort:outputPorts){
+                    List<Node> toNodes = outputPort.getToNodes();
+                    for(Node outNode:toNodes){
+                        if(outNode instanceof OutputNode){
+                            outNode.getGUI().setBodyColor(NodeState.FINISHED.color);
+                        }
+                    }
+                }
+                this.invokerMap.put(node, invoker);
 				return true;
 			}else{
                 writeProvenanceLater(node);

Modified: incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/ProvenanceWrite.java
URL: http://svn.apache.org/viewvc/incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/ProvenanceWrite.java?rev=1350392&r1=1350391&r2=1350392&view=diff
==============================================================================
--- incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/ProvenanceWrite.java
(original)
+++ incubator/airavata/branches/0.3-incubating-snapshot/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/ProvenanceWrite.java
Thu Jun 14 20:43:04 2012
@@ -39,6 +39,8 @@ import org.apache.airavata.xbaya.graph.s
 import org.apache.airavata.xbaya.graph.ws.WSNode;
 import org.apache.airavata.xbaya.invoker.Invoker;
 import org.apache.airavata.xbaya.util.XBayaUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xmlpull.infoset.XmlElement;
 
 import xsul5.XmlConstants;
@@ -47,6 +49,7 @@ import xsul5.XmlConstants;
  * @author Chathura Herath
  */
 public final class ProvenanceWrite implements PredicatedExecutable {
+    private static final Logger logger = LoggerFactory.getLogger(ProvenanceWrite.class);
 
 	private static final String PROVENANCE_DIR = "provenance";
 
@@ -182,22 +185,27 @@ public final class ProvenanceWrite imple
 				}
 				// deal with the outputs
 			}
-			XmlElement outputs = elem.newElement("outputs");
-			elem.addChild(outputs);
-
-			List<DataPort> outputPorts = node.getOutputPorts();
-			for (DataPort outputPort : outputPorts) {
-				String outputName = outputPort.getName();
-
-				XmlElement outputParamElement = outputs.newElement(outputName);
-				outputs.addChild(outputParamElement);
-				Object ouputParamValue = invokerMap.get(node).getOutput(
+            System.out.println("TEstingTEstingTEstingTEstingTEstingTEstingTEstingTEstingTEstingTEstingTEsting");
+            XmlElement outputs = elem.newElement("outputs");
+            elem.addChild(outputs);
+            int index;
+            List<DataPort> inputPorts = node.getInputPorts();
+            for (DataPort inputPort : inputPorts) {
+                String outputName = inputPort.getFromPort().getName();
+                XmlElement outputParamElement = outputs.newElement(outputName);
+                outputs.addChild(outputParamElement);
+                Object ouputParamValue = invokerMap.get(node).getOutput(
 						outputName);
-
 				if (ouputParamValue instanceof org.xmlpull.v1.builder.XmlElement) {
 					ouputParamValue = XMLUtil
 							.xmlElement3ToXmlElement5((org.xmlpull.v1.builder.XmlElement) ouputParamValue);
-				}
+				}else {
+                    try {
+                        ouputParamValue = XMLUtil.stringToXmlElement((String) ouputParamValue);
+                    } catch (Exception e) {
+                        logger.error("Error processing the output of ForEachNode");
+                    }
+                }
 
 				if (ouputParamValue != null) {
 					outputParamElement.addChild(ouputParamValue);
@@ -206,6 +214,7 @@ public final class ProvenanceWrite imple
 				}
 			}
             try {
+                System.out.println(xsul5.XmlConstants.BUILDER.serializeToString(outputs));
 				this.registry.saveWorkflowExecutionServiceOutput(new WorkflowServiceIOData(xsul5.XmlConstants.BUILDER.serializeToString(outputs),
experimentId, node.getID(),this.workflowName));
             } catch (RegistryException e) {
 				throw new XBayaException(e);



Mime
View raw message