airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1377011 - in /incubator/airavata/trunk/modules/xbaya-gui/src: main/java/org/apache/airavata/xbaya/interpretor/ main/java/org/apache/airavata/xbaya/monitor/ main/java/org/apache/airavata/xbaya/provenance/ main/java/org/apache/airavata/xbaya...
Date Fri, 24 Aug 2012 17:55:54 GMT
Author: lahiru
Date: Fri Aug 24 17:55:54 2012
New Revision: 1377011

URL: http://svn.apache.org/viewvc?rev=1377011&view=rev
Log:
supporting new Provenance Data architecture and new ProvenanceRegistry design.

Added:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowNodeStatusUpdater.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowStatusUpdater.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/WorkflowInterpretorEventListener.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorEvent.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorUtil.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/monitor/MonitorEventHandler.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/RegistryServiceTest.java

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=1377011&r1=1377010&r2=1377011&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 Aug 24 17:55:54 2012
@@ -48,6 +48,7 @@ import org.apache.airavata.common.utils.
 import org.apache.airavata.common.utils.WSDLUtil;
 import org.apache.airavata.common.utils.XMLUtil;
 import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus.ExecutionStatus;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
 import org.apache.airavata.workflow.model.component.Component;
 import org.apache.airavata.workflow.model.component.SubWorkflowComponent;
 import org.apache.airavata.workflow.model.component.amazon.InstanceComponent;
@@ -132,6 +133,9 @@ public class WorkflowInterpreter {
 
 	private WorkflowInterpreterInteractor interactor;
 
+    public static ThreadLocal<WorkflowInterpreterConfiguration> workflowInterpreterConfigurationThreadLocal
=
+            new ThreadLocal<WorkflowInterpreterConfiguration>();
+
 	/**
 	 *
 	 * Constructs a WorkflowInterpreter.
@@ -150,6 +154,7 @@ public class WorkflowInterpreter {
 					.isCollectProvenance());
 		}
 		config.setSubWorkflow(false);
+        setWorkflowInterpreterConfigurationThreadLocal(config);
 	}
 
 	public void setResourceMapping(LeadResourceMapping resourceMapping) {
@@ -1625,4 +1630,11 @@ public class WorkflowInterpreter {
 		return list;
 	}
 
+    public static void setWorkflowInterpreterConfigurationThreadLocal(WorkflowInterpreterConfiguration
workflowInterpreterConfiguration) {
+        WorkflowInterpreter.workflowInterpreterConfigurationThreadLocal.set(workflowInterpreterConfiguration);
+    }
+
+    public static WorkflowInterpreterConfiguration getWorkflowInterpreterConfiguration()
{
+        return workflowInterpreterConfigurationThreadLocal.get();
+    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java?rev=1377011&r1=1377010&r2=1377011&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
Fri Aug 24 17:55:54 2012
@@ -49,6 +49,8 @@ import org.apache.airavata.xbaya.monitor
 import org.apache.airavata.xbaya.monitor.MonitorException;
 import org.apache.airavata.xbaya.monitor.MonitorUtil;
 import org.apache.airavata.xbaya.monitor.MonitorUtil.EventType;
+import org.apache.airavata.xbaya.provenance.WorkflowNodeStatusUpdater;
+import org.apache.airavata.xbaya.provenance.WorkflowStatusUpdater;
 import org.apache.airavata.xbaya.ui.graph.NodeGUI;
 import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler.NodeState;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -67,6 +69,8 @@ public class WorkflowInterpretorEventLis
     private URI messageBoxURL;
     private String subscriptionID;
     private MessagePuller messagePuller;
+    private WorkflowStatusUpdater workflowStatusUpdater;
+    private WorkflowNodeStatusUpdater workflowNodeStatusUpdater;
 
     private static Logger logger = LoggerFactory.getLogger(WorkflowInterpretorEventListener.class);
 
@@ -78,6 +82,10 @@ public class WorkflowInterpretorEventLis
         this.messageBoxURL = configuration.getMessageBoxURL();
         this.wseClient = new WseMsgBrokerClient();
         this.wseClient.init(this.brokerURL.toString());
+        this.workflowNodeStatusUpdater = new WorkflowNodeStatusUpdater(WorkflowInterpreter.getWorkflowInterpreterConfiguration().
+                getConfiguration().getJcrComponentRegistry().getRegistry());
+        this.workflowStatusUpdater = new WorkflowStatusUpdater(WorkflowInterpreter.getWorkflowInterpreterConfiguration().
+                getConfiguration().getJcrComponentRegistry().getRegistry());
     }
 
     public void start() throws MonitorException {
@@ -160,13 +168,19 @@ public class WorkflowInterpretorEventLis
 
         if (type == MonitorUtil.EventType.WORKFLOW_INVOKED) {
             workflowStarted(graph, forward);
+            //todo ideally experimentID and workflowInstanceID has to be different
+            workflowStatusUpdater.saveWorkflowData(event.getExperimentID(), event.getExperimentID(),
+                    WorkflowInterpreter.getWorkflowInterpreterConfiguration().getWorkflow().getName());
+            workflowStatusUpdater.workflowStarted(event.getExperimentID());
         } else if (type == MonitorUtil.EventType.WORKFLOW_TERMINATED) {
             workflowFinished(graph, forward);
+            workflowStatusUpdater.workflowFinished(event.getExperimentID());
         } else if (type == EventType.INVOKING_SERVICE || type == EventType.SERVICE_INVOKED)
{
             if (node == null) {
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeStarted(node, forward);
+                workflowNodeStatusUpdater.workflowStarted(event.getExperimentID(), event.getNodeID());
             }
         } else if (type == MonitorUtil.EventType.RECEIVED_RESULT
         // TODO this should be removed when GPEL sends all notification
@@ -176,6 +190,7 @@ public class WorkflowInterpretorEventLis
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeFinished(node, forward);
+                workflowNodeStatusUpdater.workflowFinished(event.getExperimentID(), event.getNodeID());
             }
         } else if (type == EventType.INVOKING_SERVICE_FAILED || type == EventType.RECEIVED_FAULT
         // TODO
@@ -184,12 +199,14 @@ public class WorkflowInterpretorEventLis
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeFailed(node, forward);
+                workflowNodeStatusUpdater.workflowFailed(event.getExperimentID(), event.getNodeID());
             }
         } else if (type == MonitorUtil.EventType.RESOURCE_MAPPING) {
             if (node == null) {
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 // nodeResourceMapped(node, event.getEvent(), forward);
+                workflowNodeStatusUpdater.workflowRunning(event.getExperimentID(), event.getNodeID());
             }
         } else {
             // Ignore the rest.

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorEvent.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorEvent.java?rev=1377011&r1=1377010&r2=1377011&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorEvent.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorEvent.java
Fri Aug 24 17:55:54 2012
@@ -48,6 +48,8 @@ public class MonitorEvent {
 
     private String nodeID;
 
+    private String experimentID;
+
     /**
      * Constructs a MonitorEvent.
      * 
@@ -134,8 +136,9 @@ public class MonitorEvent {
         this.type = MonitorUtil.getType(this.event);
         this.workflowID = MonitorUtil.getWorkflowID(this.event);
         this.nodeID = MonitorUtil.getNodeID(this.event);
-
+        this.experimentID = MonitorUtil.getExperiementID(this.event);
         timestamp = MonitorUtil.getTimestamp(this.event);
+
         if (timestamp != null) {
             SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.S MM/dd/yy ");
             this.timeText = format.format(timestamp);
@@ -165,4 +168,7 @@ public class MonitorEvent {
 		this.timestamp = timestamp;
 	}
 
+    public String getExperimentID() {
+        return experimentID;
+    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorUtil.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorUtil.java?rev=1377011&r1=1377010&r2=1377011&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorUtil.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/monitor/MonitorUtil.java
Fri Aug 24 17:55:54 2012
@@ -90,6 +90,11 @@ public class MonitorUtil {
     public static final String BODY = "body";
 
     /**
+     * experimentID
+     * In Notification Message
+     */
+    public static final String WORKFLOW_EXPERIMENT_ID = "experimentID";
+    /**
      * workflowID
      * 
      * workflow instance ID.
@@ -370,6 +375,25 @@ public class MonitorUtil {
 
     /**
      * @param event
+     * @return The node ID if the message contains it; "", otherwise
+     */
+    public static String getExperiementID(XmlElement event) {
+        if (event == null) {
+            throw new IllegalArgumentException("null");
+        }
+        XmlElement idElement = getIDElement(event);
+        String nodeID = null;
+        if (idElement != null) {
+            nodeID = idElement.attributeValue(WOR_NS, WORKFLOW_EXPERIMENT_ID);
+        }
+        if (nodeID == null) {
+            nodeID = "";
+        }
+        return nodeID;
+    }
+
+    /**
+     * @param event
      * @return The workflow instance ID. null if there is no workflow instance ID.
      */
     public static URI getWorkflowID(XmlElement event) {

Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowNodeStatusUpdater.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowNodeStatusUpdater.java?rev=1377011&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowNodeStatusUpdater.java
(added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowNodeStatusUpdater.java
Fri Aug 24 17:55:54 2012
@@ -0,0 +1,87 @@
+/*
+ *
+ * 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.provenance;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.AiravataRegistry;
+import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WorkflowNodeStatusUpdater {
+       private static Logger logger = LoggerFactory.getLogger(WorkflowNodeStatusUpdater.class);
+
+    private AiravataRegistry registry;
+
+    public WorkflowNodeStatusUpdater(AiravataRegistry registry) {
+        this.registry = registry;
+    }
+
+    public boolean workflowStarted(String experimentID,String nodeID){
+        try {
+            registry.saveWorkflowNodeStatus(experimentID,nodeID, WorkflowInstanceStatus.ExecutionStatus.STARTED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowFailed(String experimentID,String nodeID){
+        try {
+            registry.saveWorkflowNodeStatus(experimentID,nodeID, WorkflowInstanceStatus.ExecutionStatus.FAILED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowFinished(String experimentID,String nodeID){
+        try {
+            registry.saveWorkflowNodeStatus(experimentID,nodeID, WorkflowInstanceStatus.ExecutionStatus.FINISHED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowRunning(String experimentID,String nodeID){
+        try {
+            registry.saveWorkflowNodeStatus(experimentID,nodeID, WorkflowInstanceStatus.ExecutionStatus.RUNNING);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+     public boolean workflowPaused(String experimentID,String nodeID){
+        try {
+            registry.saveWorkflowNodeStatus(experimentID,nodeID, WorkflowInstanceStatus.ExecutionStatus.PAUSED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+}

Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowStatusUpdater.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowStatusUpdater.java?rev=1377011&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowStatusUpdater.java
(added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/provenance/WorkflowStatusUpdater.java
Fri Aug 24 17:55:54 2012
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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.provenance;
+
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.AiravataRegistry;
+import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
+import org.apache.airavata.registry.api.workflow.WorkflowRunTimeData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+public class WorkflowStatusUpdater {
+    private static Logger logger = LoggerFactory.getLogger(WorkflowStatusUpdater.class);
+
+    private AiravataRegistry registry;
+
+    public WorkflowStatusUpdater(AiravataRegistry registry) {
+        this.registry = registry;
+    }
+
+    public boolean workflowStarted(String experimentID){
+        try {
+            registry.saveWorkflowExecutionStatus(experimentID, WorkflowInstanceStatus.ExecutionStatus.STARTED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowFailed(String experimentID){
+        try {
+            registry.saveWorkflowExecutionStatus(experimentID, WorkflowInstanceStatus.ExecutionStatus.FAILED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowFinished(String experimentID){
+        try {
+            registry.saveWorkflowExecutionStatus(experimentID, WorkflowInstanceStatus.ExecutionStatus.FINISHED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean workflowRunning(String experimentID){
+        try {
+            registry.saveWorkflowExecutionStatus(experimentID, WorkflowInstanceStatus.ExecutionStatus.RUNNING);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+     public boolean workflowPaused(String experimentID){
+        try {
+            registry.saveWorkflowExecutionStatus(experimentID, WorkflowInstanceStatus.ExecutionStatus.PAUSED);
+        } catch (RegistryException e) {
+            logger.error("Error updating Wokflow Node status !!");
+            return false;
+        }
+        return true;
+    }
+
+    public boolean saveWorkflowData(String experimentID,String workflowInstanceID,String
workflowTemplateID) {
+        Timestamp currentTime = new Timestamp((new java.util.Date()).getTime());
+        WorkflowRunTimeData workflowRunTimeData = new WorkflowRunTimeData(experimentID, workflowInstanceID,
workflowTemplateID, currentTime,
+                WorkflowInstanceStatus.ExecutionStatus.STARTED, currentTime);
+        try {
+            registry.saveWorkflowData(workflowRunTimeData);
+        } catch (RegistryException e) {
+            logger.error("Error saving Workflow Data !!");
+        }
+        return true;
+    }
+}

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/monitor/MonitorEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/monitor/MonitorEventHandler.java?rev=1377011&r1=1377010&r2=1377011&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/monitor/MonitorEventHandler.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/monitor/MonitorEventHandler.java
Fri Aug 24 17:55:54 2012
@@ -34,7 +34,8 @@ import java.util.Map;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
-import org.apache.airavata.common.utils.WSDLUtil;
+import org.apache.airavata.common.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
 import org.apache.airavata.workflow.model.graph.ControlPort;
 import org.apache.airavata.workflow.model.graph.EPRPort;
 import org.apache.airavata.workflow.model.graph.Edge;
@@ -49,10 +50,13 @@ import org.apache.airavata.workflow.mode
 import org.apache.airavata.workflow.model.graph.ws.WSGraph;
 import org.apache.airavata.workflow.model.wf.Workflow;
 import org.apache.airavata.xbaya.graph.controller.NodeController;
+import org.apache.airavata.xbaya.interpretor.WorkflowInterpreter;
 import org.apache.airavata.xbaya.monitor.MonitorEvent;
 import org.apache.airavata.xbaya.monitor.MonitorEventData;
 import org.apache.airavata.xbaya.monitor.MonitorUtil;
 import org.apache.airavata.xbaya.monitor.MonitorUtil.EventType;
+import org.apache.airavata.xbaya.provenance.WorkflowNodeStatusUpdater;
+import org.apache.airavata.xbaya.provenance.WorkflowStatusUpdater;
 import org.apache.airavata.xbaya.ui.XBayaGUI;
 import org.apache.airavata.xbaya.ui.graph.GraphCanvas;
 import org.apache.airavata.xbaya.ui.graph.NodeGUI;
@@ -110,6 +114,9 @@ public class MonitorEventHandler impleme
 
     private Map<Node, LinkedList<ResourcePaintable>> resourcePaintableMap;
 
+    private WorkflowStatusUpdater workflowStatusUpdater;
+
+    private WorkflowNodeStatusUpdater workflowNodeStatusUpdater;
     /**
      * Constructs a MonitorEventHandler.
      *
@@ -121,6 +128,10 @@ public class MonitorEventHandler impleme
         this.incorrectWorkflowIDs = Collections.synchronizedSet(new HashSet<URI>());
         this.triedWorkflowIDs = Collections.synchronizedSet(new HashSet<URI>());
         this.resourcePaintableMap = new HashMap<Node, LinkedList<ResourcePaintable>>();
+        this.workflowNodeStatusUpdater = new WorkflowNodeStatusUpdater(WorkflowInterpreter.getWorkflowInterpreterConfiguration().
+                getConfiguration().getJcrComponentRegistry().getRegistry());
+        this.workflowStatusUpdater = new WorkflowStatusUpdater(WorkflowInterpreter.getWorkflowInterpreterConfiguration().
+                getConfiguration().getJcrComponentRegistry().getRegistry());
     }
 
     /**
@@ -255,72 +266,6 @@ public class MonitorEventHandler impleme
     }
 
     /**
-     * @param event
-     * @param findWorkflowName
-     * @param graph
-     */
-    private void handleEvent(MonitorEvent event, String instanceName, WSGraph graph) {
-        // TODO Auto-generated method stub
-        if (-1 == instanceName.indexOf("Control_")) {
-            EventType type = event.getType();
-            String nodeID = event.getNodeID();
-            Node node = graph.getNode(nodeID);
-            if (type == MonitorUtil.EventType.WORKFLOW_INVOKED) {
-                // workflowStarted(graph, forward);
-                LinkedList<InputNode> inputNodes = getInputNodes(graph);
-                for (InputNode inputNode : inputNodes) {
-                    NodeController.getGUI(inputNode).setToken(instanceName, NodeState.FINISHED);
-                }
-            } else if (type == MonitorUtil.EventType.WORKFLOW_INITIALIZED) {
-                // workflowStarted(graph, forward);
-                LinkedList<InputNode> inputNodes = getInputNodes(graph);
-                for (InputNode inputNode : inputNodes) {
-                    NodeController.getGUI(inputNode).setToken(instanceName, NodeState.FINISHED);
-                }
-            } else if (type == MonitorUtil.EventType.WORKFLOW_TERMINATED) {
-                LinkedList<OutputNode> outputNodes = getOutputNodes(graph);
-                for (OutputNode outputNode : outputNodes) {
-                	NodeController.getGUI(outputNode).setToken(instanceName, NodeState.EXECUTING);
-                }
-            } else if (type == EventType.INVOKING_SERVICE
-            // TODO this should be removed when GPEL sends all notification
-            // correctly.
-                    || type == EventType.SERVICE_INVOKED) {
-                if (node == null) {
-                    logger.warn("There is no node that has ID, " + nodeID);
-                } else {
-                    NodeController.getGUI(node).setToken(instanceName, NodeState.EXECUTING);
-                }
-            } else if (type == MonitorUtil.EventType.RECEIVED_RESULT
-            // TODO this should be removed when GPEL sends all notification
-            // correctly.
-                    || type == EventType.SENDING_RESULT) {
-                if (node == null) {
-                    logger.warn("There is no node that has ID, " + nodeID);
-                } else {
-                    NodeController.getGUI(node).setToken(instanceName, NodeState.FINISHED);
-                }
-            } else if (type == EventType.INVOKING_SERVICE_FAILED || type == EventType.RECEIVED_FAULT
-            // TODO
-                    || type == EventType.SENDING_FAULT || type == EventType.SENDING_RESPONSE_FAILED)
{
-                if (node == null) {
-                    logger.warn("There is no node that has ID, " + nodeID);
-                } else {
-                    NodeController.getGUI(node).setToken(instanceName, NodeState.FAILED);
-                }
-            } else if (type == MonitorUtil.EventType.RESOURCE_MAPPING) {
-                if (node == null) {
-                    logger.warn("There is no node that has ID, " + nodeID);
-                } else {
-                    // nodeResourceMapped(node, event.getEvent(), forward);
-                }
-            } else {
-                // Ignore the rest.
-            }
-        }
-    }
-
-    /**
      * @param graph
      * @return
      */
@@ -359,8 +304,10 @@ public class MonitorEventHandler impleme
         // logger.info("type: " + type);
         if (type == MonitorUtil.EventType.WORKFLOW_INVOKED) {
             workflowStarted(graph, forward);
+            workflowStatusUpdater.workflowStarted(event.getExperimentID());
         } else if (type == MonitorUtil.EventType.WORKFLOW_TERMINATED) {
             workflowFinished(graph, forward);
+            workflowStatusUpdater.workflowFinished(event.getExperimentID());
         } else if (type == EventType.INVOKING_SERVICE
         // TODO this should be removed when GPEL sends all notification
         // correctly.
@@ -369,6 +316,7 @@ public class MonitorEventHandler impleme
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeStarted(node, forward);
+                workflowNodeStatusUpdater.workflowStarted(event.getExperimentID(), event.getNodeID());
             }
         } else if (type == MonitorUtil.EventType.RECEIVED_RESULT
         // TODO this should be removed when GPEL sends all notification
@@ -378,7 +326,9 @@ public class MonitorEventHandler impleme
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeFinished(node, forward);
+                workflowNodeStatusUpdater.workflowFinished(event.getExperimentID(), event.getNodeID());
             }
+
         } else if (type == EventType.INVOKING_SERVICE_FAILED || type == EventType.RECEIVED_FAULT
         // TODO
                 || type == EventType.SENDING_FAULT || type == EventType.SENDING_RESPONSE_FAILED)
{
@@ -386,12 +336,14 @@ public class MonitorEventHandler impleme
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeFailed(node, forward);
+                workflowNodeStatusUpdater.workflowFailed(event.getExperimentID(), event.getNodeID());
             }
         } else if (type == MonitorUtil.EventType.RESOURCE_MAPPING) {
             if (node == null) {
                 logger.warn("There is no node that has ID, " + nodeID);
             } else {
                 nodeResourceMapped(node, event.getEvent(), forward);
+                workflowNodeStatusUpdater.workflowRunning(event.getExperimentID(), event.getNodeID());
             }
         } else {
             // Ignore the rest.

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/RegistryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/RegistryServiceTest.java?rev=1377011&r1=1377010&r2=1377011&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/RegistryServiceTest.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/RegistryServiceTest.java
Fri Aug 24 17:55:54 2012
@@ -141,7 +141,7 @@ public class RegistryServiceTest {
     @Test
     public void getFromRegistry() throws RegistryException {
         /* Checking the registry for the saved descriptors */
-        exception.expect(ServiceDescriptionRetrieveException.class);
+//        exception.expect(ServiceDescriptionRetrieveException.class);
         assertNotNull(jcrRegistry.getHostDescription("localhost"));
         assertNull(jcrRegistry.getHostDescription("remotehost"));
 



Mime
View raw message