airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1429972 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/ airavata-client/src/main/java/org/apache/airavata/client/api/ airavata-client/src/main/java/org/apache/airavata/client/impl/ ws-messenger/messa...
Date Mon, 07 Jan 2013 19:14:46 GMT
Author: samindaw
Date: Mon Jan  7 19:14:46 2013
New Revision: 1429972

URL: http://svn.apache.org/viewvc?rev=1429972&view=rev
Log:
refactoring monitor

Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
    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/api/AiravataAPI.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/interpretor/GUIWorkflowInterpreterInteractorImpl.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java?rev=1429972&r1=1429971&r2=1429972&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataAPIFactory.java
Mon Jan  7 19:14:46 2013
@@ -48,7 +48,7 @@ public class AiravataAPIFactory {
     
     public static AiravataAPI getAPI(URI registryURL, String gateway, String username, String
alternateUsername, PasswordCallback callback) throws AiravataAPIInvocationException{
         try {
-			AiravataClient apiObj = new AiravataClient();
+			AiravataAPI apiObj = new AiravataClient();
 			apiObj.setCurrentUser(alternateUsername);
 			apiObj.setCallBack(callback);
 			apiObj.setRegitryURI(registryURL);

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=1429972&r1=1429971&r2=1429972&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
Mon Jan  7 19:14:46 2013
@@ -22,7 +22,6 @@ package org.apache.airavata.client;
 
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.List;
@@ -32,6 +31,7 @@ import java.util.Observable;
 import javax.jcr.RepositoryException;
 
 import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
 import org.apache.airavata.client.api.AiravataManager;
 import org.apache.airavata.client.api.ApplicationManager;
 import org.apache.airavata.client.api.ExecutionManager;
@@ -55,9 +55,7 @@ import org.apache.airavata.registry.api.
 import org.apache.airavata.registry.api.Gateway;
 import org.apache.airavata.registry.api.PasswordCallback;
 import org.apache.airavata.registry.api.exception.RegistryException;
-import org.apache.airavata.ws.monitor.Monitor;
 import org.apache.airavata.ws.monitor.MonitorConfiguration;
-import org.apache.airavata.ws.monitor.MonitorEventListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -208,24 +206,30 @@ public class AiravataClient extends Obse
 		}
 		return config;
 	 }
-	protected void initialize() throws MalformedURLException, AiravataConfigurationException,
RepositoryException, RegistryException {
-		if (!configCreated){
-			configuration=createConfig(getRegitryURI(), getCurrentUser(), getPassword());
-			configCreated=true;
-		}
-		updateClientConfiguration(configuration);
+	 
+	 @Override
+	public void initialize() throws AiravataAPIInvocationException {
+		try {
+			if (!configCreated){
+				configuration=createConfig(getRegitryURI(), getCurrentUser(), getPassword());
+				configCreated=true;
+			}
+			updateClientConfiguration(configuration);
 
-		// At this point we do not know the workflowExperimentId
-		// FIXME: Registry URL is set null as its not used. Set this when we
-		// have rest services
-		builder = new WorkflowContextHeaderBuilder(configuration.get(BROKER),
-				configuration.get(GFAC), null, null, null,
-				configuration.get(MSGBOX));
-
-		// TODO: At some point this should contain the current user the airavata
-		// client is
-		// logged in to the Airavata system
-		setCurrentUser(getClientConfiguration().getJcrUsername());
+			// At this point we do not know the workflowExperimentId
+			// FIXME: Registry URL is set null as its not used. Set this when we
+			// have rest services
+			builder = new WorkflowContextHeaderBuilder(configuration.get(BROKER),
+					configuration.get(GFAC), null, null, null,
+					configuration.get(MSGBOX));
+
+			// TODO: At some point this should contain the current user the airavata
+			// client is
+			// logged in to the Airavata system
+			setCurrentUser(getClientConfiguration().getJcrUsername());
+		} catch (Exception e) {
+			throw new AiravataAPIInvocationException("Error while initializing the Airavata API",e);
+		}
 	}
 
 	private void updateClientConfiguration(Map<String, String> configuration)
@@ -409,27 +413,29 @@ public class AiravataClient extends Obse
 //		// log.info("Workflow output : " + worflowoutput);
 //		return worflowoutput;
 //	}
-
-	public Monitor getWorkflowExecutionMonitor(String topic) {
-		return getWorkflowExecutionMonitor(topic, null);
-	}
-
-	public Monitor getWorkflowExecutionMonitor(String topic,
-			MonitorEventListener listener) {
-		final String fTopic = topic;
-		try {
-			monitorConfiguration = new MonitorConfiguration(new URI(
-					configuration.get(BROKER)), fTopic, true, new URI(
-					configuration.get(MSGBOX)));
-		} catch (URISyntaxException e1) {
-			e1.printStackTrace();
-		}
-		final Monitor monitor = new Monitor(monitorConfiguration);
-		monitor.setPrint(false);
-		monitor.getEventDataRepository().registerEventListener(listener);
-		listener.setExperimentMonitor(monitor);
-		return monitor;
-	}
+//
+//	public Monitor getWorkflowExecutionMonitor(String topic) {
+//		return getWorkflowExecutionMonitor(topic, null);
+//	}
+//
+//	public Monitor getWorkflowExecutionMonitor(String topic,
+//			MonitorEventListener listener) {
+//		final String fTopic = topic;
+//		MonitorConfiguration monitorConfiguration;
+//		try {
+//			monitorConfiguration = new MonitorConfiguration(
+//					getClientConfiguration().getMessagebrokerURL().toURI(), fTopic,
+//					true, getClientConfiguration().getMessageboxURL().toURI());
+//			final Monitor monitor = new Monitor(monitorConfiguration);
+//			monitor.printRawMessage(false);
+//			monitor.getEventDataRepository().registerEventListener(listener);
+//			listener.setExperimentMonitor(monitor);
+//			return monitor;
+//		} catch (URISyntaxException e) {
+//			e.printStackTrace();
+//		}
+//		
+//	}
 //
 //	private void runPreWorkflowExecutionTasks(String topic, String user,
 //			String metadata, String experimentName) throws RegistryException, AiravataConfigurationException
{

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java?rev=1429972&r1=1429971&r2=1429972&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
Mon Jan  7 19:14:46 2013
@@ -21,8 +21,11 @@
 
 package org.apache.airavata.client.api;
 
+import java.net.URI;
+
 import org.apache.airavata.client.api.builder.DescriptorBuilder;
 import org.apache.airavata.common.utils.Version;
+import org.apache.airavata.registry.api.PasswordCallback;
 
 
 /**
@@ -85,4 +88,14 @@ public interface AiravataAPI {
      */
     public DescriptorBuilder getDescriptorBuilder();
 
+	public void setCurrentUser(String alternateUsername);
+
+	public void setCallBack(PasswordCallback callback);
+
+	public void setRegitryURI(URI registryURL);
+
+	public void initialize() throws AiravataAPIInvocationException;
+
+	public void setGateway(String gateway);
+
 }
\ No newline at end of file

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=1429972&r1=1429971&r2=1429972&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
Mon Jan  7 19:14:46 2013
@@ -21,6 +21,7 @@
 
 package org.apache.airavata.client.impl;
 
+import java.net.URISyntaxException;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -51,6 +52,7 @@ import org.apache.airavata.workflow.mode
 import org.apache.airavata.ws.monitor.EventData;
 import org.apache.airavata.ws.monitor.EventDataRepository;
 import org.apache.airavata.ws.monitor.Monitor;
+import org.apache.airavata.ws.monitor.MonitorConfiguration;
 import org.apache.airavata.ws.monitor.MonitorEventListener;
 import org.apache.airavata.ws.monitor.MonitorEventListenerAdapter;
 import org.apache.airavata.ws.monitor.MonitorUtil.EventType;
@@ -131,13 +133,25 @@ public class ExecutionManagerImpl implem
 	@Override
 	public Monitor getExperimentMonitor(String experimentId)
 			throws AiravataAPIInvocationException {
-		return getClient().getWorkflowExecutionMonitor(experimentId);
+		return getExperimentMonitor(experimentId,null);
 	}
 
 	@Override
 	public Monitor getExperimentMonitor(String experimentId,MonitorEventListener listener)
 			throws AiravataAPIInvocationException {
-		return getClient().getWorkflowExecutionMonitor(experimentId,listener);
+		MonitorConfiguration monitorConfiguration;
+		try {
+			monitorConfiguration = new MonitorConfiguration(
+					getClient().getClientConfiguration().getMessagebrokerURL().toURI(), experimentId,
+					true, getClient().getClientConfiguration().getMessageboxURL().toURI());
+			final Monitor monitor = new Monitor(monitorConfiguration);
+			monitor.printRawMessage(false);
+			monitor.getEventDataRepository().registerEventListener(listener);
+			listener.setExperimentMonitor(monitor);
+			return monitor;
+		} catch (URISyntaxException e) {
+			throw new AiravataAPIInvocationException(e);
+		}
 	}
 
 	//------------------Deprecated Functions---------------------//

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=1429972&r1=1429971&r2=1429972&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
Mon Jan  7 19:14:46 2013
@@ -48,9 +48,9 @@ public class Monitor extends EventProduc
 
     protected WsmgClient wsmgClient;
 
-    protected boolean print;
+    protected boolean printRawMessages;
 
-    protected long timeout = 20000L;
+    protected long messagePullTimeout = 20000L;
 
     protected boolean monitoring = false;
     
@@ -58,23 +58,14 @@ public class Monitor extends EventProduc
     
     private boolean monitoringFailed=false;
     
-    /**
-     * Constructs a Monitor.
-     * 
-     * @param configuration
-     */
     public Monitor(MonitorConfiguration configuration) {
         this.configuration = configuration;
-        // The first one is special and it is for the main event panel display
-        // and
-        // it does not have and filters
+        // First one keeps all event data & it doesn't have filters
         this.eventDataMap.put(DEFAULT_MODEL_KEY, new EventDataRepository());
-
-
     }
 
     /**
-     * @return The configuration
+     * @return The configuration for monitoring
      */
     public MonitorConfiguration getConfiguration() {
         return this.configuration;
@@ -85,7 +76,6 @@ public class Monitor extends EventProduc
      * @return 
      */
     public EventDataRepository getEventDataRepository() {
-        // send the first one cos that is the default one
         return this.eventDataMap.get(DEFAULT_MODEL_KEY);
     }
 
@@ -102,13 +92,15 @@ public class Monitor extends EventProduc
      * @throws MonitorException
      */
     public synchronized void start() throws MonitorException {
-
+    	
+    	//Make sure currently we are not doing any monitoring
         stop();
 
-        // Stop the previous monitoring if any.
+        // Reset monitoring variables
     	monitoringCompleted=false;
     	monitoringFailed=false;
-    			
+
+    	//Notify listeners that the monitoring is about to start
     	getEventDataRepository().triggerListenerForPreMonitorStart();
 
         subscribe();
@@ -121,9 +113,6 @@ public class Monitor extends EventProduc
                 final String nodeID = string;
                 // for each wsnode there is one data model which
                 this.eventDataMap.put(nodeID, new EventDataRepository(new EventFilter() {
-                    /**
-                     * @see org.apache.airavata.ws.monitor.EventFilter#isAcceptable(org.apache.airavata.ws.monitor.EventData)
-                     */
                     public boolean isAcceptable(EventData event) {
                         return event != null && event.getNodeID() != null &&
event.getNodeID().equals(nodeID);
                     }
@@ -133,14 +122,34 @@ public class Monitor extends EventProduc
         }
         getEventDataRepository().triggerListenerForPostMonitorStart();
     }
-    
+
+    /**
+     * Stops monitoring without using a thread.
+     * 
+     * @throws MonitorException
+     */
+    public synchronized void stop() throws MonitorException {
+        try {
+			if (this.wsmgClient != null) {
+				getEventDataRepository().triggerListenerForPreMonitorStop();
+			    unsubscribe(this.wsmgClient);
+			    this.wsmgClient = null;
+			    getEventDataRepository().triggerListenerForPostMonitorStop();
+			}
+		} finally{
+	        monitoringCompleted=true;
+		}
+    }
+
+    /**
+     * Start monitoring asynchronously
+     */
     public void startMonitoring(){
-    	final Monitor m=this;
     	new Thread(){
     		@Override
     		public void run() {
     			try {
-					m.start();
+    				Monitor.this.start();
 				} catch (MonitorException e) {
 					e.printStackTrace();
 				}
@@ -148,15 +157,11 @@ public class Monitor extends EventProduc
     	}.start();
     }
     
-    public void stopMonitoring(){
-		asynchronousStop();
-    }
-
     /**
-     * Stops monitoring.
+     * Stop monitoring asynchronously
      */
-    protected void asynchronousStop() {
-        // Users don't need to know the end of unsubscription.
+    public void stopMonitoring(){
+    	// Users don't need to know the end of unsubscription.
         new Thread() {
             @Override
             public void run() {
@@ -171,27 +176,9 @@ public class Monitor extends EventProduc
     }
 
     /**
-     * Stops monitoring without using a thread.
-     * 
-     * @throws MonitorException
-     */
-    public synchronized void stop() throws MonitorException {
-        try {
-			if (this.wsmgClient != null) {
-				getEventDataRepository().triggerListenerForPreMonitorStop();
-			    unsubscribe(this.wsmgClient);
-			    this.wsmgClient = null;
-			    getEventDataRepository().triggerListenerForPostMonitorStop();
-			}
-		} finally{
-	        monitoringCompleted=true;
-		}
-    }
-
-    /**
-     * Resets the graph and clear the monitoring table. Remove all the extra tablemodels
available
+     * Resets the graph and clear the monitoring table. Remove all the extra table models
available
      */
-    public void reset() {
+    public void resetEventData() {
         Set<String> keys = this.eventDataMap.keySet();
         LinkedList<String> keysToBeRemoved = new LinkedList<String>();
         // Remove everthing leaving only the last one
@@ -211,10 +198,10 @@ public class Monitor extends EventProduc
     /**
      * @param event
      */
-    public synchronized void handleNotification(XmlElement event) {
+    protected synchronized void handleNotification(XmlElement event) {
         Set<String> keys = this.eventDataMap.keySet();
         // Remove everthing leaving only the last one
-        if(print){
+        if(printRawMessages){
             System.out.println(XMLUtil.xmlElementToString(event));
         }
         for (String key : keys) {
@@ -222,10 +209,14 @@ public class Monitor extends EventProduc
         }
     }
 
+    /**
+     * Subscribe to the WS Messenger client to pull notifications from the message box
+     * @throws MonitorException
+     */
     private void subscribe() throws MonitorException {
         this.wsmgClient = new WsmgClient(this);
-        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.setTimeout(this.getMessagePullTimeout());
         this.wsmgClient.subscribe();
         setMonitoring(true);
 
@@ -233,10 +224,14 @@ public class Monitor extends EventProduc
         sendSafeEvent(new Event(Type.MONITOR_STARTED));
     }
 
+    /**
+     * Unsubcribe from the ws messager client
+     * @param client
+     * @throws MonitorException
+     */
     private void unsubscribe(WsmgClient client) throws MonitorException {
         // Enable/disable some menu items.
         sendSafeEvent(new Event(Type.MONITOR_STOPED));
-
         client.unsubscribe();
         setMonitoring(false);
     }
@@ -259,7 +254,7 @@ public class Monitor extends EventProduc
      * @param print - if <code>true</code> raw notifications are printed
      */
     public void printRawMessage(boolean print){
-    	this.print = print;
+    	this.printRawMessages = print;
     }
     
     /**
@@ -267,7 +262,7 @@ public class Monitor extends EventProduc
      * @return
      */
     public long getMessagePullTimeout() {
-        return timeout;
+        return messagePullTimeout;
     }
 
     /**
@@ -275,7 +270,7 @@ public class Monitor extends EventProduc
      * @param timeout
      */
     public void setMessagePullTimeout(long timeout) {
-        this.timeout = timeout;
+        this.messagePullTimeout = timeout;
     }
 
     /**
@@ -320,6 +315,6 @@ public class Monitor extends EventProduc
      * @param print - if <code>true</code> raw notifications are printed
      */
     public void setPrint(boolean print) {
-        this.print = print;
+        this.printRawMessages = print;
     }
 }
\ No newline at end of file

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/GUIWorkflowInterpreterInteractorImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/GUIWorkflowInterpreterInteractorImpl.java?rev=1429972&r1=1429971&r2=1429972&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/GUIWorkflowInterpreterInteractorImpl.java
(original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/GUIWorkflowInterpreterInteractorImpl.java
Mon Jan  7 19:14:46 2013
@@ -119,7 +119,7 @@ public class GUIWorkflowInterpreterInter
 			} catch (MonitorException e) {
 				e.printStackTrace();
 			} finally {
-				this.engine.getMonitor().reset();
+				this.engine.getMonitor().resetEventData();
 			}
 			break;
 		case HANDLE_DEPENDENT_NODES_DIFFERED_INPUTS:

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=1429972&r1=1429971&r2=1429972&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
Mon Jan  7 19:14:46 2013
@@ -241,7 +241,7 @@ public class RunMenuItem  implements Eve
         item.setMnemonic(KeyEvent.VK_R);
         item.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent event) {
-                engine.getMonitor().reset();
+                engine.getMonitor().resetEventData();
             }
         });
         item.setVisible(false);



Mime
View raw message