airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1429590 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/ airavata-client/src/main/java/org/apache/airavata/client/impl/ ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/ xbaya...
Date Sun, 06 Jan 2013 20:14:27 GMT
Author: samindaw
Date: Sun Jan  6 20:14:27 2013
New Revision: 1429590

URL: http://svn.apache.org/viewvc?rev=1429590&view=rev
Log:
refactoring the Monitor API

Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
    airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/Monitor.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/views/MonitorPanel.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=1429590&r1=1429589&r2=1429590&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
Sun Jan  6 20:14:27 2013
@@ -448,7 +448,7 @@ public class AiravataClient extends Obse
 		}
 		final Monitor monitor = new Monitor(monitorConfiguration);
 		monitor.setPrint(false);
-		monitor.getEventData().registerEventListener(listener);
+		monitor.getEventDataRepository().registerEventListener(listener);
 		listener.setExperimentMonitor(monitor);
 		return monitor;
 	}

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java?rev=1429590&r1=1429589&r2=1429590&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
Sun Jan  6 20:14:27 2013
@@ -30,7 +30,6 @@ import java.util.UUID;
 import javax.xml.stream.XMLStreamException;
 
 import org.apache.airavata.client.AiravataClient;
-import org.apache.airavata.client.AiravataClientConfiguration;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
 import org.apache.airavata.client.api.ExecutionManager;
 import org.apache.airavata.client.api.ExperimentAdvanceOptions;
@@ -40,7 +39,6 @@ import org.apache.airavata.client.stub.i
 import org.apache.airavata.client.stub.interpretor.WorkflowInterpretorStub;
 import org.apache.airavata.common.utils.XMLUtil;
 import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
-import org.apache.airavata.registry.api.workflow.WorkflowExecution;
 import org.apache.airavata.registry.api.workflow.WorkflowExecutionStatus;
 import org.apache.airavata.registry.api.workflow.WorkflowExecutionStatus.State;
 import org.apache.airavata.workflow.model.component.ComponentException;
@@ -133,7 +131,6 @@ public class ExecutionManagerImpl implem
 	@Override
 	public WorkflowContextHeaderBuilder createWorkflowContextHeader()
 			throws AiravataAPIInvocationException {
-		AiravataClientConfiguration config = getClient().getClientConfiguration();
 		try {
 			return new WorkflowContextHeaderBuilder(null,
 					null,null,null,null,

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=1429590&r1=1429589&r2=1429590&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
Sun Jan  6 20:14:27 2013
@@ -52,7 +52,7 @@ public class Monitor extends EventProduc
 
     protected long timeout = 20000L;
 
-    protected boolean status = false;
+    protected boolean monitoring = false;
     
     private boolean monitoringCompleted=false;
     
@@ -81,18 +81,20 @@ public class Monitor extends EventProduc
     }
 
     /**
-     * @return The event data;
+     * Return the event data repository containing all the notifications
+     * @return 
      */
-    public EventDataRepository getEventData() {
+    public EventDataRepository getEventDataRepository() {
         // send the first one cos that is the default one
         return this.eventDataMap.get(DEFAULT_MODEL_KEY);
     }
 
     /**
-     * @return The event data;
+     * Return the event data repository containing all the notifications for the node
+     * @param nodeID
+     * @return
      */
-    public EventDataRepository getEventData(String nodeID) {
-        // send the first one cos that is the default one
+    public EventDataRepository getEventDataRepository(String nodeID){
         return this.eventDataMap.get(nodeID);
     }
 
@@ -104,7 +106,7 @@ public class Monitor extends EventProduc
     	monitoringCompleted=false;
     	monitoringFailed=false;
     			
-    	getEventData().triggerListenerForPreMonitorStart();
+    	getEventDataRepository().triggerListenerForPreMonitorStart();
         asynchronousStop();
 
         subscribe();
@@ -127,7 +129,7 @@ public class Monitor extends EventProduc
             }
 
         }
-        getEventData().triggerListenerForPostMonitorStart();
+        getEventDataRepository().triggerListenerForPostMonitorStart();
     }
     
     public void startMonitoring(){
@@ -145,41 +147,25 @@ public class Monitor extends EventProduc
     }
     
     public void stopMonitoring(){
-    	final Monitor m=this;
-    	new Thread(){
-    		@Override
-    		public void run() {
-    			try {
-					m.stop();
-				} catch (MonitorException e) {
-					e.printStackTrace();
-				}
-    		}
-    	}.start();
+		asynchronousStop();
     }
 
     /**
      * Stops monitoring.
      */
-    public synchronized void asynchronousStop() {
-        if (this.wsmgClient != null) {
-            // To make thread safe.
-            final WsmgClient client = this.wsmgClient;
-            this.wsmgClient = null;
-
-            // Users don't need to know the end of unsubscription.
-            new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        unsubscribe(client);
-                    } catch (WorkflowException e) {
-                        // Ignore the error in unsubscription.
-                        logger.error(e.getMessage(), e);
-                    }
+    protected void asynchronousStop() {
+        // Users don't need to know the end of unsubscription.
+        new Thread() {
+            @Override
+            public void run() {
+                try {
+                	Monitor.this.stop();
+                } catch (WorkflowException e) {
+                    // Ignore the error in unsubscription.
+                    logger.error(e.getMessage(), e);
                 }
-            }.start();
-        }
+            }
+        }.start();
     }
 
     /**
@@ -190,10 +176,10 @@ public class Monitor extends EventProduc
     public synchronized void stop() throws MonitorException {
         try {
 			if (this.wsmgClient != null) {
-				getEventData().triggerListenerForPreMonitorStop();
+				getEventDataRepository().triggerListenerForPreMonitorStop();
 			    unsubscribe(this.wsmgClient);
 			    this.wsmgClient = null;
-			    getEventData().triggerListenerForPostMonitorStop();
+			    getEventDataRepository().triggerListenerForPostMonitorStop();
 			}
 		} finally{
 	        monitoringCompleted=true;
@@ -236,10 +222,10 @@ public class Monitor extends EventProduc
 
     private void subscribe() throws MonitorException {
         this.wsmgClient = new WsmgClient(this);
-        this.wsmgClient.setTimeout(this.getTimeout());
+        this.wsmgClient.setTimeout(this.getMessagePullTimeout());
         //Users can set the timeout and interval for the subscription using wsmg setter methods,
here we use the default values
         this.wsmgClient.subscribe();
-        this.status = true;
+        setMonitoring(true);
 
         // Enable/disable some menu items and show the monitor panel.
         sendSafeEvent(new Event(Type.MONITOR_STARTED));
@@ -250,36 +236,80 @@ public class Monitor extends EventProduc
         sendSafeEvent(new Event(Type.MONITOR_STOPED));
 
         client.unsubscribe();
-        this.status = false;
+        setMonitoring(false);
     }
-
-    public void setPrint(boolean print) {
-        this.print = print;
+    
+    /**
+     * Wait until the monitoring is completed
+     */
+    public void waitForCompletion(){
+    	while(!monitoringCompleted && !monitoringFailed){
+    		try {
+				Thread.sleep(100);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+    	}
     }
-
-    public long getTimeout() {
+    
+    /**
+     * Print the raw notification messages to the console as they arrive
+     * @param print - if <code>true</code> raw notifications are printed
+     */
+    public void printRawMessage(boolean print){
+    	this.print = print;
+    }
+    
+    /**
+     * Retrieve the timeout in milliseconds for pulling messages
+     * @return
+     */
+    public long getMessagePullTimeout() {
         return timeout;
     }
 
-    public void setTimeout(long timeout) {
+    /**
+     * Set the timeout in milliseconds for pulling messages
+     * @param timeout
+     */
+    public void setMessagePullTimeout(long timeout) {
         this.timeout = timeout;
     }
 
-    public boolean isStatus() {
-        return status;
+    /**
+     * is the monitoring active
+     * @return
+     */
+    public boolean isMonitoring() {
+        return monitoring;
     }
 
-    public void setStatus(boolean status) {
-        this.status = status;
+    private void setMonitoring(boolean monitoring) {
+        this.monitoring = monitoring;
     }
     
-    public void waitForCompletion(){
-    	while(!monitoringCompleted && !monitoringFailed){
-    		try {
-				Thread.sleep(100);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-    	}
+    /**
+     * @deprecated - Use <code>getEventDataRepository()</code> instead
+     * @return
+     */
+    public EventDataRepository getEventData(){
+    	return getEventDataRepository();
+    }
+    
+    /**
+     * @deprecated - Use <code>getEventDataRepository(...)</code> instead
+     * @param nodeID
+     * @return
+     */
+    public EventDataRepository getEventData(String nodeID) {
+        return getEventDataRepository(nodeID);
+    }
+    
+    /**
+     * @deprecated - Use <code>printRawMessage(...)</code> instead
+     * @param print - if <code>true</code> raw notifications are printed
+     */
+    public void setPrint(boolean print) {
+        this.print = print;
     }
 }
\ No newline at end of file

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java?rev=1429590&r1=1429589&r2=1429590&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
(original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/test/WorkflowModificationTestCase.java
Sun Jan  6 20:14:27 2013
@@ -134,7 +134,7 @@ public class WorkflowModificationTestCas
             monitor = new Monitor(monitorConfiguration);
         }
 
-        EventDataRepository eventData = monitor.getEventData();
+        EventDataRepository eventData = monitor.getEventDataRepository();
         MonitorCallback callback = new MonitorCallback(eventData);
         LoopbackPublisher publisher = new LoopbackPublisher(callback, this.configuration.getTopic());
         MonitorNotifier notifier = new MonitorNotifier(publisher);

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java?rev=1429590&r1=1429589&r2=1429590&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
(original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
Sun Jan  6 20:14:27 2013
@@ -40,8 +40,8 @@ import org.apache.airavata.ws.monitor.Mo
 import org.apache.airavata.ws.monitor.MonitorConfiguration;
 import org.apache.airavata.ws.monitor.MonitorException;
 import org.apache.airavata.ws.monitor.event.Event;
-import org.apache.airavata.ws.monitor.event.EventListener;
 import org.apache.airavata.ws.monitor.event.Event.Type;
+import org.apache.airavata.ws.monitor.event.EventListener;
 import org.apache.airavata.xbaya.XBayaConfiguration;
 import org.apache.airavata.xbaya.XBayaConfiguration.XBayaExecutionMode;
 import org.apache.airavata.xbaya.XBayaEngine;
@@ -221,7 +221,7 @@ public class RunMenuItem  implements Eve
         AbstractAction action = new AbstractAction() {
             public void actionPerformed(ActionEvent event) {
                 try {
-                    engine.getMonitor().asynchronousStop();
+                    engine.getMonitor().stopMonitoring();
                 } catch (RuntimeException e) {
                     engine.getGUI().getErrorWindow().error(ErrorMessages.MONITOR_ERROR, e);
                 } catch (Error e) {
@@ -312,7 +312,7 @@ public class RunMenuItem  implements Eve
         AbstractAction action = new AbstractAction() {
             private WorkflowInterpreterLaunchWindow window;
             public void actionPerformed(ActionEvent e) {
-                if(engine.getMonitor().isStatus()){
+                if(engine.getMonitor().isMonitoring()){
                     if (JOptionPane.showConfirmDialog(null,
                             "A previous workflow execution data needs to be cleared before
launching another workflow. Do you wish to continue?",
                             "Run Workflow", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/views/MonitorPanel.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/views/MonitorPanel.java?rev=1429590&r1=1429589&r2=1429590&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/views/MonitorPanel.java
(original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/views/MonitorPanel.java
Sun Jan  6 20:14:27 2013
@@ -89,7 +89,7 @@ public class MonitorPanel implements XBa
     public MonitorPanel(XBayaGUI xbayaGUI, String nodeID, Monitor monitor) {
         this.xbayaGUI=xbayaGUI;
         if (null == nodeID) {
-            this.tableSliderModel = monitor.getEventData();
+            this.tableSliderModel = monitor.getEventDataRepository();
         } else {
             this.tableSliderModel = monitor.getEventData(nodeID);
         }



Mime
View raw message