You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/11/03 16:51:50 UTC

[06/29] git commit: fix bug where tasks (eg pollers) are not stopped on unmanagement if the task which started the tasks is the same one which is unmanaging the entity

fix bug where tasks (eg pollers) are not stopped on unmanagement if the task which started the tasks is the same one which is unmanaging the entity


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

Branch: refs/heads/master
Commit: 6432a1270f1c95131e943ca52e89a3f132c2348c
Parents: 44382b7
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Oct 24 23:51:36 2014 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Oct 31 09:38:19 2014 -0500

----------------------------------------------------------------------
 .../java/brooklyn/management/internal/LocalEntityManager.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6432a127/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java b/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
index 4acb9b4..c6a5bcf 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
@@ -38,6 +38,7 @@ import brooklyn.entity.Application;
 import brooklyn.entity.Entity;
 import brooklyn.entity.Group;
 import brooklyn.entity.basic.AbstractEntity;
+import brooklyn.entity.basic.BrooklynTaskTags;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.basic.EntityPredicates;
@@ -421,8 +422,12 @@ public class LocalEntityManager implements EntityManagerInternal {
         try {
             Set<Task<?>> tasksCancelled = MutableSet.of();
             for (Task<?> t: managementContext.getExecutionContext(entity).getTasks()) {
-                if (hasTaskAsAncestor(t, Tasks.current()))
+                if (entity.equals(BrooklynTaskTags.getContextEntity(Tasks.current())) && hasTaskAsAncestor(t, Tasks.current())) {
+                    // don't cancel if we are running inside a task on the target entity and
+                    // the task being considered is one we have submitted -- e.g. on "stop" don't cancel ourselves!
+                    // but if our current task is from another entity we probably do want to cancel them (we are probably invoking unmanage)
                     continue;
+                }
                 
                 if (!t.isDone()) {
                     try {