airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: Change experiment status to CANCELLED after stop the original experiment process due to cancelling request
Date Fri, 22 May 2015 21:16:16 GMT
Repository: airavata
Updated Branches:
  refs/heads/master c6ac2b176 -> 72110910a


Change experiment status to CANCELLED after stop the original experiment process due to cancelling
request


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

Branch: refs/heads/master
Commit: 72110910a98e68f5b93b94cd0a19e91790206a27
Parents: c6ac2b1
Author: shamrath <shameerainfo@gmail.com>
Authored: Fri May 22 17:16:01 2015 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Fri May 22 17:16:01 2015 -0400

----------------------------------------------------------------------
 .../airavata/gfac/core/cpi/BetterGfacImpl.java  | 61 +++++++++++++++-----
 1 file changed, 45 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/72110910/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
index 5e66d1d..8859390 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
@@ -908,6 +908,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                     }
                 }else{
                     log.info("Experiment execution is cancelled, so InHandler invocation
is going to stop");
+                    GFacUtils.publishTaskStatus(jobExecutionContext, monitorPublisher, TaskState.CANCELED);
                     break;
                 }
             }
@@ -962,7 +963,7 @@ public class BetterGfacImpl implements GFac,Watcher {
             try {
                 monitorPublisher.publish(new GfacExperimentStateChangeRequest(new MonitorID(jobExecutionContext),
GfacExperimentState.OUTHANDLERSINVOKING));
                 for (GFacHandlerConfig handlerClassName : handlers) {
-                    if (!isCancelled(jobExecutionContext)) {
+                    if (!isCancel(jobExecutionContext)) {
                         Class<? extends GFacHandler> handlerClass;
                         GFacHandler handler;
                         try {
@@ -995,7 +996,10 @@ public class BetterGfacImpl implements GFac,Watcher {
                             throw new GFacException(e);
                         }
                     } else {
-                        log.info("Experiment execution is cancelled, so OutHandler invocation
is going to stop");
+                        log.info("Experiment execution is cancelled, so OutHandler invocation
is stopped");
+                        if (isCancelling(jobExecutionContext)) {
+                            GFacUtils.publishTaskStatus(jobExecutionContext, monitorPublisher,
TaskState.CANCELED);
+                        }
                         break;
                     }
                 }
@@ -1218,30 +1222,55 @@ public class BetterGfacImpl implements GFac,Watcher {
     }
 
 
-    public boolean isCancelled(JobExecutionContext executionContext) throws RegistryException
{
+    public boolean isCancelled(JobExecutionContext executionContext){
         // we should check whether experiment is cancelled using registry
-        ExperimentStatus status = (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS,
executionContext.getExperimentID());
-        if (status != null){
-            ExperimentState experimentState = status.getExperimentState();
-            if (experimentState != null){
-                if(experimentState == ExperimentState.CANCELED){
-                    return true;
+        try {
+            ExperimentStatus status = (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS,
executionContext.getExperimentID());
+            if (status != null){
+                ExperimentState experimentState = status.getExperimentState();
+                if (experimentState != null){
+                    if(experimentState == ExperimentState.CANCELED){
+                        return true;
+                    }
                 }
             }
+        } catch (RegistryException e) {
+            // on error we return false.
         }
         return false;
     }
 
-    public boolean isCancelling(JobExecutionContext executionContext) throws RegistryException
{
+    public boolean isCancelling(JobExecutionContext executionContext){
         // check whether cancelling request came
-        ExperimentStatus status = (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS,
executionContext.getExperimentID());
-        if (status != null){
-            ExperimentState experimentState = status.getExperimentState();
-            if (experimentState != null){
-                if(experimentState == ExperimentState.CANCELING){
-                    return true;
+        try {
+            ExperimentStatus status = (ExperimentStatus)registry.get(RegistryModelType.EXPERIMENT_STATUS,
executionContext.getExperimentID());
+            if (status != null){
+                ExperimentState experimentState = status.getExperimentState();
+                if (experimentState != null){
+                    if(experimentState == ExperimentState.CANCELING){
+                        return true;
+                    }
+                }
+            }
+        } catch (RegistryException e) {
+            // on error we return false;
+        }
+        return false;
+    }
+
+    public boolean isCancel(JobExecutionContext jobExecutionContext) {
+        try {
+            ExperimentStatus status = registry.get(RegistryModelType.EXPERIMENT_STATUS, jobExecutionContext.getExperimentID());
+            if (status != null) {
+                ExperimentState experimentState = status.getExperimentState();
+                if (experimentState != null) {
+                    if (experimentState == ExperimentState.CANCELING || experimentState ==
ExperimentState.CANCELED) {
+                        return true;
+                    }
                 }
             }
+        } catch (RegistryException e) {
+            // on error we return false;
         }
         return false;
     }


Mime
View raw message