Fixing Gracefully handling multiple launch requests
@@ -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,6 +356,10 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
public boolean launchProcess(String processId, String airavataCredStoreToken, String gatewayId) throws TException {
final RegistryService.Client registryClient = getRegistryServiceClient();
try {
+ ProcessStatus processStatus = registryClient.getProcessStatus(processId);
+
+ switch (processStatus.getState()) {
+ case CREATED: case VALIDATED:
ProcessModel processModel = registryClient.getProcess(processId);
String applicationId = processModel.getApplicationInterfaceId();
if (applicationId == null) {
@@ -367,6 +373,12 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
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);
