You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2013/01/05 21:54:49 UTC

svn commit: r1429385 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/api/ airavata-client/src/main/java/org/apache/airavata/client/impl/ registry/airavata-jpa-registry/ ws-messenger/message-monitor/ ws-messenger/m...

Author: samindaw
Date: Sat Jan  5 20:54:49 2013
New Revision: 1429385

URL: http://svn.apache.org/viewvc?rev=1429385&view=rev
Log:
adding wait for experiment termination funtion to the API

Added:
    airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java   (with props)
Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ExecutionManagerImpl.java
    airavata/trunk/modules/registry/airavata-jpa-registry/   (props changed)
    airavata/trunk/modules/ws-messenger/message-monitor/   (props changed)

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java?rev=1429385&r1=1429384&r2=1429385&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java (original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ExecutionManager.java Sat Jan  5 20:54:49 2013
@@ -154,5 +154,12 @@ public interface ExecutionManager {
      * @throws AiravataAPIInvocationException
      */
     public ExperimentAdvanceOptions createExperimentAdvanceOptions(String experimentName, String experimentUser, String experimentMetadata) throws AiravataAPIInvocationException;
+    
+    /**
+     * Returns when the given experiment has completed
+     * @param experimentId
+     * @throws AiravataAPIInvocationException
+     */
+    public void waitForExperimentTermination(String experimentId) throws AiravataAPIInvocationException;
 
 }

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=1429385&r1=1429384&r2=1429385&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 Sat Jan  5 20:54:49 2013
@@ -40,13 +40,20 @@ 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;
 import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
 import org.apache.airavata.workflow.model.graph.GraphException;
 import org.apache.airavata.workflow.model.wf.Workflow;
 import org.apache.airavata.workflow.model.wf.WorkflowInput;
+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.MonitorEventListener;
+import org.apache.airavata.ws.monitor.MonitorEventListenerAdapter;
+import org.apache.airavata.ws.monitor.MonitorUtil.EventType;
 import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
 import org.apache.axis2.AxisFault;
 
@@ -302,4 +309,29 @@ public class ExecutionManagerImpl implem
 		return options;
 	}
 
+	@Override
+	public void waitForExperimentTermination(String experimentId)
+			throws AiravataAPIInvocationException {
+		Monitor experimentMonitor = getExperimentMonitor(experimentId, new MonitorEventListenerAdapter() {
+			@Override
+			public void notify(EventDataRepository eventDataRepo,
+					EventData eventData) {
+				if (eventData.getType()==EventType.WORKFLOW_TERMINATED){
+					getMonitor().stopMonitoring();
+				}
+			}
+		});
+		experimentMonitor.startMonitoring();
+		try {
+			WorkflowExecutionStatus workflowInstanceStatus = getClient().getProvenanceManager().getWorkflowInstanceStatus(experimentId, experimentId);
+			if (workflowInstanceStatus.getExecutionStatus()==State.FINISHED || workflowInstanceStatus.getExecutionStatus()==State.FAILED){
+				experimentMonitor.stopMonitoring();
+				return;
+			}
+		} catch (AiravataAPIInvocationException e) {
+			//Workflow may not have started yet. Best to use the monitor to follow the progress 
+		}
+		experimentMonitor.waitForCompletion();
+	}
+
 }

Propchange: airavata/trunk/modules/registry/airavata-jpa-registry/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jan  5 20:54:49 2013
@@ -0,0 +1 @@
+target

Propchange: airavata/trunk/modules/ws-messenger/message-monitor/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jan  5 20:54:49 2013
@@ -0,0 +1 @@
+target

Added: airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java?rev=1429385&view=auto
==============================================================================
--- airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java (added)
+++ airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java Sat Jan  5 20:54:49 2013
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.ws.monitor;
+
+public abstract class MonitorEventListenerAdapter implements MonitorEventListener {
+	private Monitor monitor;
+	
+	@Override
+	public void setExperimentMonitor(Monitor monitor) {
+		setMonitor(monitor);
+	}
+
+	@Override
+	public void monitoringPreStart() {
+		//Nothing to do
+	}
+
+	@Override
+	public void monitoringPostStart() {
+		//Nothing to do
+	}
+
+	@Override
+	public void monitoringPreStop() {
+		//Nothing to do
+	}
+
+	@Override
+	public void monitoringPostStop() {
+		//Nothing to do
+	}
+
+	protected Monitor getMonitor() {
+		return monitor;
+	}
+
+	private void setMonitor(Monitor monitor) {
+		this.monitor = monitor;
+	}
+
+}

Propchange: airavata/trunk/modules/ws-messenger/message-monitor/src/main/java/org/apache/airavata/ws/monitor/MonitorEventListenerAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain