Author: lahiru
Date: Wed Jan 16 21:41:05 2013
New Revision: 1434417

URL: http://svn.apache.org/viewvc?rev=1434417&view=rev
Log:
fixing embedded invoker.

Modified:
    
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
    
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
    
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java

Modified: 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java?rev=1434417&r1=1434416&r2=1434417&view=diff
==============================================================================
--- 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
 (original)
+++ 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
 Wed Jan 16 21:41:05 2013
@@ -191,14 +191,18 @@ public class WorkflowInterpreter {
                 
this.getConfig().getConfiguration().getAiravataAPI().getProvenanceManager().setWorkflowInstanceNodeInput(workflowInstanceNode,
 keywords[i] + "=" + (String) values[i]);
                 
this.getConfig().getConfiguration().getAiravataAPI().getProvenanceManager().setWorkflowNodeType(workflowInstanceNode,
 workflowNodeType);
                        }
+            System.out.println("********************- 1");
                        this.config.getNotifier().workflowStarted(values, 
keywords);
                        while (this.getWorkflow().getExecutionState() != 
WorkflowExecutionState.STOPPED) {
+                System.out.println("********************- 2");
                                if (getRemainNodesDynamically() == 0) {
+                    System.out.println("********************- 3");
                                        
notifyViaInteractor(WorkflowExecutionMessage.EXECUTION_STATE_CHANGED, 
WorkflowExecutionState.PAUSED);
                                }
                                // ok we have paused sleep
                                while (this.getWorkflow().getExecutionState() 
== WorkflowExecutionState.PAUSED) {
                                        try {
+                        System.out.println("********************- 4");
                                                Thread.sleep(400);
                                        } catch (InterruptedException e) {
                                                e.printStackTrace();
@@ -207,6 +211,7 @@ public class WorkflowInterpreter {
                                // get task list and execute them
                                ArrayList<Node> readyNodes = 
this.getReadyNodesDynamically();
                                for (Node node : readyNodes) {
+                    System.out.println("********************- 5");
                                        if (node.isBreak()) {
                                                this.notifyPause();
                                                break;
@@ -214,9 +219,6 @@ public class WorkflowInterpreter {
                                        if 
(this.getWorkflow().getExecutionState() == WorkflowExecutionState.PAUSED
                                                        || 
this.getWorkflow().getExecutionState() == WorkflowExecutionState.STOPPED) {
                                                break;
-//                                             // stop executing and sleep in 
the outer loop cause we
-//                                             // want
-//                                             // recalculate the execution 
stack
                                        }
                                        executeDynamically(node);
                                        if 
(this.getWorkflow().getExecutionState() == WorkflowExecutionState.STEP) {
@@ -1131,7 +1133,6 @@ public class WorkflowInterpreter {
                        for (Iterator<String> iterator = 
listOfValues.iterator(); iterator.hasNext();) {
                                String input = iterator.next();
                                final String gfacURLString = 
this.getConfig().getConfiguration().getGFacURL().toString();
-
                                WSComponent wsComponent = (WSComponent) 
middleNode.getComponent();
                                invoker = 
createInvokerForEachSingleWSNode(middleNode, gfacURLString, wsComponent);
                                invokerList.add(invoker);
@@ -1347,6 +1348,8 @@ public class WorkflowInterpreter {
                ArrayList<Node> list = new ArrayList<Node>();
                ArrayList<Node> waiting = 
InterpreterUtil.getWaitingNodesDynamically(this.getGraph());
                ArrayList<Node> finishedNodes = 
InterpreterUtil.getFinishedNodesDynamically(this.getGraph());
+        System.out.println("waiting:" + waiting.size());
+        System.out.println("finishedNodes:" + finishedNodes.size());
                for (Node node : waiting) {
                        Component component = node.getComponent();
                        if (component instanceof WSComponent
@@ -1382,6 +1385,7 @@ public class WorkflowInterpreter {
                                        inputsDone = inputsDone && 
finishedNodes.contains(dataPort.getFromNode());
                                }
                                if (inputsDone && controlDone) {
+                    System.out.println("***************** Added ************");
                                        list.add(node);
                                }
                        } else if (component instanceof EndifComponent) {

Modified: 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java?rev=1434417&r1=1434416&r2=1434417&view=diff
==============================================================================
--- 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
 (original)
+++ 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
 Wed Jan 16 21:41:05 2013
@@ -22,13 +22,6 @@ package org.apache.airavata.xbaya.invoke
 
 import java.io.StringReader;
 import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
@@ -37,7 +30,6 @@ import javax.xml.stream.XMLStreamReader;
 
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
-import 
org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
 import org.apache.airavata.core.gfac.exception.ProviderException;
 import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.common.utils.XMLUtil;
@@ -49,18 +41,15 @@ import org.apache.airavata.core.gfac.con
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.message.impl.ParameterContextImpl;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
-//import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.schemas.gfac.InputParameterType;
 import org.apache.airavata.schemas.gfac.Parameter;
 import org.apache.airavata.schemas.gfac.ServiceDescriptionType;
 import org.apache.airavata.workflow.model.exceptions.WorkflowException;
-import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
 import org.apache.airavata.xbaya.XBayaConfiguration;
 import org.apache.airavata.xbaya.jython.lib.ServiceNotifiable;
 import org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable;
 import org.apache.axiom.om.*;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -92,7 +81,7 @@ public class EmbeddedGFacInvoker impleme
     private XBayaConfiguration configuration;
 
 
-    private Future<Boolean> result;
+    private Boolean result;
 
     private ServiceNotifiable notifier;
 
@@ -232,7 +221,6 @@ public class EmbeddedGFacInvoker impleme
             }
             this.inputNames.add(name);
             this.inputValues.add(value);
-
         } catch (RuntimeException e) {
             logger.error(e.getMessage(), e);
             String message = "Error in setting an input. name: " + name + " 
value: " + value;
@@ -287,6 +275,7 @@ public class EmbeddedGFacInvoker impleme
                 // Send notification
                 logger.debug("outputMessage: " + outputElement.toString());
                 outPut = new 
WSIFMessageElement(XMLUtil.stringToXmlElement3(outputElement.toStringWithConsume()));
+                this.result = true;
                 EmbeddedGFacInvoker.this.notifier.serviceFinished(new 
WSIFMessageElement((XmlElement) outPut));
             } else {
                 // An implementation of WSIFMessage,
@@ -346,7 +335,7 @@ public class EmbeddedGFacInvoker impleme
                 }
             }
             // Wait for the job to finish.
-            Boolean success = this.result.get();
+            Boolean success = this.result;
             if (success == false) {
                 WSIFMessage faultMessage = this.invoker.getFault();
                 String message = "Error in a service: ";
@@ -356,13 +345,6 @@ public class EmbeddedGFacInvoker impleme
                 message += faultMessage.toString();
                 throw new WorkflowException(message);
             }
-        } catch (InterruptedException e) {
-            logger.error(e.getMessage(), e);
-        } catch (ExecutionException e) {
-            // The service-failed notification should have been sent already.
-            logger.error(e.getMessage(), e);
-            String message = "Error in invoking a service: " + 
this.serviceInformation;
-            throw new WorkflowException(message, e);
         } catch (RuntimeException e) {
             logger.error(e.getMessage(), e);
             String message = "Error while waiting for a service to finish: " + 
this.serviceInformation;
@@ -384,7 +366,11 @@ public class EmbeddedGFacInvoker impleme
     public Object getOutput(String name) throws WorkflowException {
         try {
             waitToFinish();
-            return outPut;
+            if (outPut instanceof XmlElement) {
+                    return ((XmlElement)((XmlElement)((XmlElement) 
outPut).children().next()).children().next()).children().next();
+            } else  {
+                return outPut;
+            }
         } catch (WorkflowException e) {
             logger.error(e.getMessage(), e);
             // An appropriate message has been set in the exception.
@@ -442,7 +428,7 @@ public class EmbeddedGFacInvoker impleme
             Object value = this.inputValues.get(index);
             InputParameterType parameter = 
serviceDescriptionType.getInputParametersArray(index);
             if (value instanceof XmlElement) {
-                omElement.setText((String)((XmlElement) 
value).children().next());
+                    
omElement.setText((String)((XmlElement)((XmlElement)((XmlElement) 
value).children().next()).children().next()).children().next());
                 XMLStreamReader reader = 
XMLInputFactory.newInstance().createXMLStreamReader(new 
StringReader(XMLUtil.xmlElementToString((XmlElement) value)));
                 StAXOMBuilder builder = new StAXOMBuilder(reader);
                 OMElement input = builder.getDocumentElement();

Modified: 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java?rev=1434417&r1=1434416&r2=1434417&view=diff
==============================================================================
--- 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java
 (original)
+++ 
airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java
 Wed Jan 16 21:41:05 2013
@@ -244,7 +244,8 @@ public class NotificationSender implemen
      */
     @Override
     public void workflowFailed(String message, Throwable e) {
-        logger.error(e.getMessage(), e);
+        if(e != null)
+            logger.error(e.getMessage(), e);
         if (message == null || "".equals(message)) {
             message = "Error";
         }


Reply via email to