airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: Only allow terminate operation for running experiments.
Date Mon, 23 Nov 2015 20:04:13 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop 9e4dccffc -> bb5be4b5e


Only allow terminate operation for running experiments.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/bb5be4b5
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/bb5be4b5
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/bb5be4b5

Branch: refs/heads/develop
Commit: bb5be4b5edf91eaf7d54c4564e9615e3bd5021b9
Parents: 9e4dccf
Author: Shameera Rathnayaka <shameerainfo@gmail.com>
Authored: Mon Nov 23 15:03:49 2015 -0500
Committer: Shameera Rathnayaka <shameerainfo@gmail.com>
Committed: Mon Nov 23 15:03:49 2015 -0500

----------------------------------------------------------------------
 .../server/OrchestratorServerHandler.java       | 38 ++++++++++++--------
 1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/bb5be4b5/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
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 c1e9d65..94e804d 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
@@ -345,20 +345,30 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface
{
 	}
 
     private boolean validateStatesAndCancel(String experimentId, String gatewayId) throws
Exception {
-	    String expCancelNodePath = ZKPaths.makePath(ZKPaths.makePath(ZkConstants.ZOOKEEPER_EXPERIMENT_NODE,
-			    experimentId), ZkConstants.ZOOKEEPER_CANCEL_LISTENER_NODE);
-	    Stat stat = curatorClient.checkExists().forPath(expCancelNodePath);
-	    if (stat != null) {
-		    curatorClient.setData().withVersion(-1).forPath(expCancelNodePath, ZkConstants.ZOOKEEPER_CANCEL_REQEUST
-				    .getBytes());
-		    ExperimentStatus status = new ExperimentStatus(ExperimentState.CANCELING);
-		    status.setReason("Experiment cancel request processed");
-		    status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
-		    OrchestratorUtils.updageExperimentStatus(experimentId, status);
-		    log.info("expId : " + experimentId + " :- Experiment status updated to " + status.getState());
-		    return true;
-	    }
-	    return false;
+		ExperimentStatus experimentStatus = OrchestratorUtils.getExperimentStatus(experimentId);
+		switch (experimentStatus.getState()) {
+			case COMPLETED: case CANCELED: case FAILED: case CANCELING:
+				log.warn("Can't terminate already {} experiment", experimentStatus.getState().name());
+				return false;
+			case CREATED:
+				log.warn("Experiment termination is only allowed for launched experiments.");
+				return false;
+			default:
+				String expCancelNodePath = ZKPaths.makePath(ZKPaths.makePath(ZkConstants.ZOOKEEPER_EXPERIMENT_NODE,
+						experimentId), ZkConstants.ZOOKEEPER_CANCEL_LISTENER_NODE);
+				Stat stat = curatorClient.checkExists().forPath(expCancelNodePath);
+				if (stat != null) {
+					curatorClient.setData().withVersion(-1).forPath(expCancelNodePath, ZkConstants.ZOOKEEPER_CANCEL_REQEUST
+							.getBytes());
+					ExperimentStatus status = new ExperimentStatus(ExperimentState.CANCELING);
+					status.setReason("Experiment cancel request processed");
+					status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
+					OrchestratorUtils.updageExperimentStatus(experimentId, status);
+					log.info("expId : " + experimentId + " :- Experiment status updated to " + status.getState());
+					return true;
+				}
+				return false;
+		}
     }
 
     private void launchWorkflowExperiment(String experimentId, String airavataCredStoreToken)
throws TException {


Mime
View raw message