You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2019/05/03 15:38:05 UTC

[airavata] branch master updated: Fixing AIRAVATA-3022: Gracefully handling multiple launch requests

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/master by this push:
     new 88b8047  Fixing AIRAVATA-3022: Gracefully handling multiple launch requests
88b8047 is described below

commit 88b8047b2dca73fea3b01bfc01f642537f15f1cc
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Fri May 3 11:37:56 2019 -0400

    Fixing AIRAVATA-3022: Gracefully handling multiple launch requests
---
 .../server/OrchestratorServerHandler.java          | 38 ++++++++++++++--------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index 6741575..90ea7bb 100644
--- a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -45,6 +45,8 @@ import org.apache.airavata.model.messaging.event.*;
 import org.apache.airavata.model.process.ProcessModel;
 import org.apache.airavata.model.status.ExperimentState;
 import org.apache.airavata.model.status.ExperimentStatus;
+import org.apache.airavata.model.status.ProcessState;
+import org.apache.airavata.model.status.ProcessStatus;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.schedule.HostScheduler;
 import org.apache.airavata.orchestrator.core.utils.OrchestratorConstants;
@@ -354,19 +356,29 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
 	public boolean launchProcess(String processId, String airavataCredStoreToken, String gatewayId) throws TException {
 		final RegistryService.Client registryClient = getRegistryServiceClient();
 		try {
-			ProcessModel processModel = registryClient.getProcess(processId);
-            String applicationId = processModel.getApplicationInterfaceId();
-			if (applicationId == null) {
-                log.error(processId, "Application interface id shouldn't be null.");
-				throw new OrchestratorException("Error executing the job, application interface id shouldn't be null.");
-			}
-			// set application deployment id to process model
-            ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(registryClient, processModel, applicationId);
-            processModel.setApplicationDeploymentId(applicationDeploymentDescription.getAppDeploymentId());
-			// set compute resource id to process model, default we set the same in the user preferred compute host id
-			processModel.setComputeResourceId(processModel.getProcessResourceSchedule().getResourceHostId());
-			registryClient.updateProcess(processModel,processModel.getProcessId());
-		    return orchestrator.launchProcess(processModel, airavataCredStoreToken);
+            ProcessStatus processStatus = registryClient.getProcessStatus(processId);
+
+            switch (processStatus.getState()) {
+                case CREATED: case VALIDATED:
+                    ProcessModel processModel = registryClient.getProcess(processId);
+                    String applicationId = processModel.getApplicationInterfaceId();
+                    if (applicationId == null) {
+                        log.error(processId, "Application interface id shouldn't be null.");
+                        throw new OrchestratorException("Error executing the job, application interface id shouldn't be null.");
+                    }
+                    // set application deployment id to process model
+                    ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(registryClient, processModel, applicationId);
+                    processModel.setApplicationDeploymentId(applicationDeploymentDescription.getAppDeploymentId());
+                    // set compute resource id to process model, default we set the same in the user preferred compute host id
+                    processModel.setComputeResourceId(processModel.getProcessResourceSchedule().getResourceHostId());
+                    registryClient.updateProcess(processModel, processModel.getProcessId());
+                    return orchestrator.launchProcess(processModel, airavataCredStoreToken);
+
+                default:
+                    log.warn("Process " + processId + " is already launched. So it can not be relaunched");
+                    return false;
+            }
+
 		} catch (Exception e) {
             log.error(processId, "Error while launching process ", e);
             throw new TException(e);