airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1427970 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/ integration-tests/src/test/java/org/apache/airavata/integration/ ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/
Date Wed, 02 Jan 2013 19:44:38 GMT
Author: samindaw
Date: Wed Jan  2 19:44:38 2013
New Revision: 1427970

URL: http://svn.apache.org/viewvc?rev=1427970&view=rev
Log:
update monitor listner & update the integration tests

Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
    airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
    airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/TestMonitorListener.java
    airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java
    airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventData.java
    airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListener.java

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
Wed Jan  2 19:44:38 2013
@@ -449,6 +449,7 @@ public class AiravataClient extends Obse
 		final Monitor monitor = new Monitor(monitorConfiguration);
 		monitor.setPrint(true);
 		monitor.getEventData().registerEventListener(listener);
+		listener.setExperimentMonitor(monitor);
 		return monitor;
 	}
 

Modified: airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
(original)
+++ airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
Wed Jan  2 19:44:38 2013
@@ -312,7 +312,7 @@ public class BaseCaseIT {
         while ((line = reader.readLine()) != null) {
             buffer.append(line);
         }
-
+        reader.close();
         log.debug("Workflow compose - " + buffer.toString());
         return buffer.toString();
     }
@@ -320,8 +320,9 @@ public class BaseCaseIT {
     public void monitor(String experimentId) throws Exception {
         AiravataAPI airavataAPI = AiravataAPIFactory.getAPI(new URI(getRegistryURL()), getGatewayName(),
                 getUserName(), new PasswordCallbackImpl() );
-        Monitor experimentMonitor = airavataAPI.getExecutionManager().getExperimentMonitor(experimentId,
    // TODO what is experiment name ?
-                new TestMonitorListener(this.airavataAPI, experimentId));
+        TestMonitorListener monitorListener = new TestMonitorListener(this.airavataAPI, experimentId);
+		Monitor experimentMonitor = airavataAPI.getExecutionManager().getExperimentMonitor(experimentId,
    // TODO what is experiment name ?
+                monitorListener);
         experimentMonitor.startMonitoring();
     }
 

Modified: airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/TestMonitorListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/TestMonitorListener.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/TestMonitorListener.java
(original)
+++ airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/TestMonitorListener.java
Wed Jan  2 19:44:38 2013
@@ -1,11 +1,14 @@
 package org.apache.airavata.integration;
 
+import java.util.List;
+
 import junit.framework.Assert;
+
 import org.apache.airavata.client.api.AiravataAPI;
-import org.apache.airavata.registry.api.workflow.ExperimentData;
 import org.apache.airavata.registry.api.impl.WorkflowExecutionDataImpl;
+import org.apache.airavata.registry.api.workflow.ExperimentData;
 import org.apache.airavata.registry.api.workflow.NodeExecutionData;
-import org.apache.airavata.registry.api.workflow.WorkflowExecutionData;
+import org.apache.airavata.ws.monitor.Monitor;
 import org.apache.airavata.ws.monitor.MonitorEvent;
 import org.apache.airavata.ws.monitor.MonitorEventData;
 import org.apache.airavata.ws.monitor.MonitorEventListener;
@@ -13,8 +16,6 @@ import org.apache.airavata.ws.monitor.Mo
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 /**
  * Monitor class for integration tests.
  */
@@ -24,6 +25,7 @@ public class TestMonitorListener impleme
 
     private String experimentId;
     private AiravataAPI airavataAPI;
+    private Monitor experimentMonitor;
 
     public TestMonitorListener(AiravataAPI api, String experiment) {
         this.airavataAPI = api;
@@ -39,6 +41,7 @@ public class TestMonitorListener impleme
         if (MonitorUtil.EventType.WORKFLOW_TERMINATED == event.getType()) {
             try {
                 verifyOutput("echo_output=Airavata Test");
+                getExperimentMonitor().stopMonitoring();
             } catch (Exception e) {
                 log.error("Error verifying output", e);
                 throw new RuntimeException(e);
@@ -67,4 +70,30 @@ public class TestMonitorListener impleme
             }
         }
     }
+
+	private Monitor getExperimentMonitor() {
+		return experimentMonitor;
+	}
+
+	@Override
+	public void setExperimentMonitor(Monitor monitor) {
+		this.experimentMonitor = monitor;
+	}
+
+	@Override
+	public void monitoringPreStart() {
+	}
+
+	@Override
+	public void monitoringPostStart() {
+	}
+
+	@Override
+	public void monitoringPreStop() {
+	}
+
+	@Override
+	public void monitoringPostStop() {
+	}
+
 }

Modified: airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java
(original)
+++ airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java
Wed Jan  2 19:44:38 2013
@@ -97,6 +97,7 @@ public class Monitor extends EventProduc
      */
     public synchronized void start() throws MonitorException {
         // Stop the previous monitoring if any.
+    	getEventData().triggerListenerForPreMonitorStart();
         asynchronousStop();
 
         subscribe();
@@ -119,6 +120,7 @@ public class Monitor extends EventProduc
             }
 
         }
+        getEventData().triggerListenerForPostMonitorStart();
     }
     
     public void startMonitoring(){
@@ -134,6 +136,20 @@ public class Monitor extends EventProduc
     		}
     	}.start();
     }
+    
+    public void stopMonitoring(){
+    	final Monitor m=this;
+    	new Thread(){
+    		@Override
+    		public void run() {
+    			try {
+					m.stop();
+				} catch (MonitorException e) {
+					e.printStackTrace();
+				}
+    		}
+    	}.start();
+    }
 
     /**
      * Stops monitoring.
@@ -165,10 +181,12 @@ public class Monitor extends EventProduc
      * @throws MonitorException
      */
     public synchronized void stop() throws MonitorException {
+    	getEventData().triggerListenerForPreMonitorStop();
         if (this.wsmgClient != null) {
             unsubscribe(this.wsmgClient);
             this.wsmgClient = null;
         }
+        getEventData().triggerListenerForPostMonitorStop();
     }
 
     /**

Modified: airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventData.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventData.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventData.java
(original)
+++ airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventData.java
Wed Jan  2 19:44:38 2013
@@ -137,18 +137,63 @@ public class MonitorEventData implements
             // The muxmum of the slider changed regardless whether we move the
             // slider or not.
             fireSliderChanged();
-            for (MonitorEventListener listener : getMonitorEventListerners()) {
-				try {
-					listener.notify(this, event);
-				} catch (Exception e) {
-					//just in case
-					e.printStackTrace();
-				}
-			}
-
+            triggerListenerForMonitorEvent(event);
         }
 
     }
+    public void triggerListenerForPreMonitorStart() {
+		for (MonitorEventListener listener : getMonitorEventListerners()) {
+			try {
+				listener.monitoringPreStart();
+			} catch (Exception e) {
+				//just in case
+				e.printStackTrace();
+			}
+		}
+	}
+    
+    public void triggerListenerForPostMonitorStart() {
+		for (MonitorEventListener listener : getMonitorEventListerners()) {
+			try {
+				listener.monitoringPostStart();
+			} catch (Exception e) {
+				//just in case
+				e.printStackTrace();
+			}
+		}
+	}
+    
+    public void triggerListenerForPreMonitorStop() {
+		for (MonitorEventListener listener : getMonitorEventListerners()) {
+			try {
+				listener.monitoringPreStop();
+			} catch (Exception e) {
+				//just in case
+				e.printStackTrace();
+			}
+		}
+	}
+    
+    public void triggerListenerForPostMonitorStop() {
+		for (MonitorEventListener listener : getMonitorEventListerners()) {
+			try {
+				listener.monitoringPostStop();
+			} catch (Exception e) {
+				//just in case
+				e.printStackTrace();
+			}
+		}
+	}
+	private void triggerListenerForMonitorEvent(MonitorEvent event) {
+		for (MonitorEventListener listener : getMonitorEventListerners()) {
+			try {
+				listener.notify(this, event);
+			} catch (Exception e) {
+				//just in case
+				e.printStackTrace();
+			}
+		}
+	}
 
     /**
      * @return All events.

Modified: airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListener.java?rev=1427970&r1=1427969&r2=1427970&view=diff
==============================================================================
--- airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListener.java
(original)
+++ airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListener.java
Wed Jan  2 19:44:38 2013
@@ -23,4 +23,10 @@ package org.apache.airavata.ws.monitor;
 
 public interface MonitorEventListener {
 	public void notify(MonitorEventData eventData, MonitorEvent event);
+	public void setExperimentMonitor(Monitor monitor);
+	public void monitoringPreStart();
+	public void monitoringPostStart();
+	
+	public void monitoringPreStop();
+	public void monitoringPostStop();
 }



Mime
View raw message