brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [11/22] incubator-brooklyn git commit: treat tasks submitted by transient tasks as transient by default
Date Wed, 24 Jun 2015 08:05:22 GMT
treat tasks submitted by transient tasks as transient by default


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/63e8c061
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/63e8c061
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/63e8c061

Branch: refs/heads/master
Commit: 63e8c061634bb19f0cfe3f253b436aaa7cb0668e
Parents: 61d4821
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Jun 20 16:33:41 2015 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Jun 24 00:40:33 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java | 7 ++++++-
 .../main/java/brooklyn/util/task/BasicExecutionContext.java   | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/63e8c061/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
index 41b2371..e90a014 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
@@ -267,7 +267,12 @@ public class BrooklynTaskTags extends TaskTags {
     
     public static void setInessential(Task<?> task) { addTagDynamically(task, INESSENTIAL_TASK);
}
     public static void setTransient(Task<?> task) { addTagDynamically(task, TRANSIENT_TASK_TAG);
}
-    public static boolean isTransient(Task<?> task) { return hasTag(task, TRANSIENT_TASK_TAG);
}
+    public static boolean isTransient(Task<?> task) { 
+        if (hasTag(task, TRANSIENT_TASK_TAG)) return true;
+        if (hasTag(task, NON_TRANSIENT_TASK_TAG)) return true;
+        if (task.getSubmittedByTask()!=null) return isTransient(task.getSubmittedByTask());
+        return false;
+    }
     public static boolean isSubTask(Task<?> task) { return hasTag(task, SUB_TASK_TAG);
}
     public static boolean isEffectorTask(Task<?> task) { return hasTag(task, EFFECTOR_TAG);
}
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/63e8c061/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java b/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
index bff6e2d..6346ecd 100644
--- a/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
+++ b/core/src/main/java/brooklyn/util/task/BasicExecutionContext.java
@@ -169,6 +169,11 @@ public class BasicExecutionContext extends AbstractExecutionContext {
 
         taskTags.addAll(tags);
         
+        if (Tasks.current()!=null && BrooklynTaskTags.isTransient(Tasks.current())
&& !taskTags.contains(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG)) {
+            // tag as transient if submitter is transient, unless explicitly tagged as non-transient
+            taskTags.add(BrooklynTaskTags.TRANSIENT_TASK_TAG);
+        }
+        
         final Object startCallback = properties.get("newTaskStartCallback");
         properties.put("newTaskStartCallback", new Function<Object,Void>() {
             public Void apply(Object it) {


Mime
View raw message