airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject svn commit: r1437509 - in /airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples: MonitorListener.java MonitorWorkflow.java RunWorkflow.java
Date Wed, 23 Jan 2013 15:58:26 GMT
Author: raminder
Date: Wed Jan 23 15:58:25 2013
New Revision: 1437509

URL: http://svn.apache.org/viewvc?rev=1437509&view=rev
Log:
Added sample for Job monitoring. AIRAVATA-650

Added:
    airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorListener.java
    airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorWorkflow.java
Modified:
    airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/RunWorkflow.java

Added: airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorListener.java?rev=1437509&view=auto
==============================================================================
--- airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorListener.java
(added)
+++ airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorListener.java
Wed Jan 23 15:58:25 2013
@@ -0,0 +1,62 @@
+package org.apache.airavata.client.samples;
+
+import org.apache.airavata.ws.monitor.EventData;
+import org.apache.airavata.ws.monitor.EventDataListener;
+import org.apache.airavata.ws.monitor.EventDataRepository;
+import org.apache.airavata.ws.monitor.Monitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorListener implements EventDataListener {
+
+	private static final Logger log = LoggerFactory.getLogger(MonitorListener.class);
+
+	@Override
+	public void notify(EventDataRepository eventDataRepo, EventData eventData) {
+		log.info("ExperimentID: " + eventData.getExperimentID());
+		log.info("Message: " + eventData.getMessage());
+	}
+
+	@Override
+	public void setExperimentMonitor(Monitor monitor) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void monitoringPreStart() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void monitoringPostStart() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void monitoringPreStop() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void monitoringPostStop() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void onFail(EventData failNotification) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void onCompletion(EventData completionNotification) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

Added: airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorWorkflow.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorWorkflow.java?rev=1437509&view=auto
==============================================================================
--- airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorWorkflow.java
(added)
+++ airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/MonitorWorkflow.java
Wed Jan 23 15:58:25 2013
@@ -0,0 +1,29 @@
+package org.apache.airavata.client.samples;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.airavata.client.AiravataAPIFactory;
+import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
+import org.apache.airavata.registry.api.PasswordCallback;
+import org.apache.airavata.rest.client.PasswordCallbackImpl;
+import org.apache.airavata.ws.monitor.Monitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorWorkflow {
+	private static final Logger log = LoggerFactory.getLogger(MonitorWorkflow.class);
+
+	public static void monitor(final String experimentId) throws AiravataAPIInvocationException,
URISyntaxException {
+		PasswordCallback passwordCallback = new PasswordCallbackImpl(RunWorkflow.getUserName(),
+				RunWorkflow.getPassword());
+		AiravataAPI airavataAPI = AiravataAPIFactory.getAPI(new URI(RunWorkflow.getRegistryURL()),
+				RunWorkflow.getGatewayName(), RunWorkflow.getUserName(), passwordCallback);
+		MonitorListener monitorListener = new MonitorListener();
+		Monitor experimentMonitor = airavataAPI.getExecutionManager().getExperimentMonitor(experimentId,
+				monitorListener);
+		log.info("Started the Workflow monitor");
+		experimentMonitor.startMonitoring();
+	}
+}

Modified: airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/RunWorkflow.java
URL: http://svn.apache.org/viewvc/airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/RunWorkflow.java?rev=1437509&r1=1437508&r2=1437509&view=diff
==============================================================================
--- airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/RunWorkflow.java
(original)
+++ airavata/trunk/samples/airavata-client/workflow-run/src/main/java/org/apache/airavata/client/samples/RunWorkflow.java
Wed Jan 23 15:58:25 2013
@@ -20,32 +20,30 @@
 */
 package org.apache.airavata.client.samples;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.airavata.client.AiravataAPIFactory;
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
-import org.apache.airavata.client.api.ExperimentAdvanceOptions;
 import org.apache.airavata.registry.api.PasswordCallback;
 import org.apache.airavata.registry.api.exception.worker.ExperimentLazyLoadedException;
 import org.apache.airavata.registry.api.impl.WorkflowExecutionDataImpl;
 import org.apache.airavata.registry.api.workflow.ExperimentData;
-import org.apache.airavata.registry.api.workflow.WorkflowExecutionData;
+import org.apache.airavata.registry.api.workflow.InputData;
 import org.apache.airavata.registry.api.workflow.NodeExecutionData;
+import org.apache.airavata.registry.api.workflow.OutputData;
 import org.apache.airavata.rest.client.PasswordCallbackImpl;
 import org.apache.airavata.workflow.model.wf.WorkflowInput;
-import org.apache.airavata.registry.api.workflow.InputData;
-import org.apache.airavata.registry.api.workflow.OutputData;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
 public class RunWorkflow {
     private static final Logger log = LoggerFactory.getLogger(RunWorkflow.class);
 
@@ -100,7 +98,8 @@ public class RunWorkflow {
                 = airavataAPI.getExecutionManager().runExperiment(workflowName, workflowInputs);
 
         System.out.println("Experiment ID Returned : " + result);
-		airavataAPI.getExecutionManager().waitForExperimentTermination(result);
+        MonitorWorkflow.monitor(result);
+        airavataAPI.getExecutionManager().waitForExperimentTermination(result);
         ExperimentData experimentData = airavataAPI.getProvenanceManager().getExperimentData(result);
         List<WorkflowExecutionDataImpl> workflowInstanceData
                 = experimentData.getWorkflowExecutionDataList();



Mime
View raw message