brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [8/9] git commit: tidies after code reviwe for stopping tasks on unmanagement, and option for stopping tasks with timeout and investigation of errors occurring on rapid entity destroying just to make sure they are benign and handled well (and they are :)
Date Fri, 17 Oct 2014 10:24:18 GMT
tidies after code reviwe for stopping tasks on unmanagement, and option for stopping tasks
with timeout and investigation of errors occurring on rapid entity destroying just to make
sure they are benign and handled well (and they are :) )


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

Branch: refs/heads/master
Commit: e1e0acf6afe2dd2c01abf562960f5e470af9e636
Parents: 48396f9
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Oct 17 11:06:44 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Oct 17 11:06:44 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/basic/AbstractEntity.java   |  5 +++
 .../java/brooklyn/entity/basic/Entities.java    |  6 ++++
 .../entity/basic/ServiceStateLogic.java         |  5 +++
 .../internal/BrooklynGarbageCollector.java      |  6 ++--
 .../management/internal/LocalEntityManager.java | 36 ++++++++++++++++++++
 .../internal/LocalLocationManager.java          | 16 ++++++---
 .../internal/LocalSubscriptionManager.java      | 12 ++++++-
 .../util/task/BasicExecutionManager.java        | 32 ++++++++---------
 .../brooklyn/entity/rebind/RebindFeedTest.java  |  1 +
 .../brooklyn/management/ha/HotStandbyTest.java  |  2 +-
 .../internal/EntityExecutionManagerTest.java    | 19 ++++++++---
 .../proxy/nginx/NginxRebindIntegrationTest.java |  5 +--
 .../nginx/NginxRebindWithHaIntegrationTest.java | 24 +++++++------
 .../src/main/java/brooklyn/test/Asserts.java    |  2 +-
 14 files changed, 129 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
index 51077ee..46383c0 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
@@ -70,6 +70,7 @@ import brooklyn.management.internal.EffectorUtils;
 import brooklyn.management.internal.EntityManagementSupport;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.management.internal.SubscriptionTracker;
+import brooklyn.management.internal.NonDeploymentManagementContext.NonDeploymentManagementContextMode;
 import brooklyn.mementos.EntityMemento;
 import brooklyn.policy.Enricher;
 import brooklyn.policy.EnricherSpec;
@@ -87,6 +88,7 @@ import brooklyn.util.flags.FlagUtils;
 import brooklyn.util.flags.TypeCoercions;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.task.DeferredSupplier;
+import brooklyn.util.task.Tasks;
 import brooklyn.util.text.Strings;
 
 import com.google.common.annotations.Beta;
@@ -1307,6 +1309,9 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
     }
     
     public <T> void emitInternal(Sensor<T> sensor, T val) {
+        if (getManagementSupport().isNoLongerManaged())
+            throw new IllegalStateException("Entity "+this+" is no longer managed, when trying
to publish "+sensor+" "+val);
+
         SubscriptionContext subsContext = getSubscriptionContext();
         if (subsContext != null) subsContext.publish(sensor.newEvent(getProxyIfAvailable(),
val));
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/entity/basic/Entities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Entities.java b/core/src/main/java/brooklyn/entity/basic/Entities.java
index 6af7252..3624551 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -665,8 +665,14 @@ public class Entities {
                 log.debug("destroyed and unmanaged read-only copy of "+e);
             } else {
                 if (e instanceof Startable) Entities.invokeEffector((EntityLocal)e, e, Startable.STOP).getUnchecked();
+                
+                // TODO if destroying gracefully we might also want to do this:
+//                ((LocalEntityManager)e.getApplication().getManagementContext().getEntityManager()).stopTasks(e,
null);
+                
                 if (e instanceof EntityInternal) ((EntityInternal)e).destroy();
+                
                 unmanage(e);
+                
                 log.debug("destroyed and unmanaged "+e+"; mgmt now "+
                     (e.getApplicationId()==null ? "(no app)" : e.getApplication().getManagementContext())+"
- managed? "+isManaged(e));
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
index abe5d94..049eff1 100644
--- a/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
+++ b/core/src/main/java/brooklyn/entity/basic/ServiceStateLogic.java
@@ -285,6 +285,11 @@ public class ServiceStateLogic {
 
         protected void setActualState(@Nullable Lifecycle state) {
             if (log.isTraceEnabled()) log.trace("{} setting actual state {}", this, state);
+            if (((EntityInternal)entity).getManagementSupport().isNoLongerManaged()) {
+                // won't catch everything, but catches some
+                log.debug(entity+" is no longer managed when told to set actual state to
"+state+"; suppressing");
+                return;
+            }
             emit(SERVICE_STATE_ACTUAL, (state==null ? Entities.REMOVE : state));
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
index fdc734a..c69e6b3 100644
--- a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
+++ b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
@@ -223,8 +223,8 @@ public class BrooklynGarbageCollector {
             "storage: " + storage.getStorageMetrics() + "; " +
             "tasks: " +
             executionManager.getNumActiveTasks()+" active, "+
-            executionManager.getNumInMemoryTasks()+" in memory "+
-            "("+executionManager.getNumIncompleteTasks()+" incomplete and "+
+            executionManager.getNumIncompleteTasks()+" unfinished; "+
+            executionManager.getNumInMemoryTasks()+" remembered, "+
             executionManager.getTotalTasksSubmitted()+" total submitted)";
     }
     
@@ -235,6 +235,8 @@ public class BrooklynGarbageCollector {
     }
     
     public void onUnmanaged(Entity entity) {
+        // defer task deletions until the entity is completely unmanaged
+        // (this is usually invoked during the stop sequence)
         synchronized (unmanagedEntitiesNeedingGc) {
             unmanagedEntitiesNeedingGc.put(entity, Tasks.current());
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/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 8aeb8ac..9438759 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalEntityManager.java
@@ -29,6 +29,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
 
+import javax.annotation.Nullable;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,8 +60,11 @@ import brooklyn.util.collections.MutableSet;
 import brooklyn.util.collections.SetFromLiveMap;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.task.Tasks;
+import brooklyn.util.time.CountdownTimer;
+import brooklyn.util.time.Duration;
 
 import com.google.api.client.repackaged.com.google.common.base.Preconditions;
+import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -402,9 +407,18 @@ public class LocalEntityManager implements EntityManagerInternal {
     }
     
     private void stopTasks(Entity entity) {
+        stopTasks(entity, null);
+    }
+    
+    /** stops all tasks (apart from any current one or its descendants) on this entity,
+     * optionally -- if a timeout is given -- waiting for completion and warning on incomplete
tasks */
+    @Beta
+    public void stopTasks(Entity entity, @Nullable Duration timeout) {
+        CountdownTimer timeleft = timeout==null ? null : timeout.countdownTimer();
         // try forcibly interrupting tasks on managed entities
         Collection<Exception> exceptions = MutableSet.of();
         try {
+            Set<Task<?>> tasksCancelled = MutableSet.of();
             for (Task<?> t: managementContext.getExecutionContext(entity).getTasks())
{
                 if (hasTaskAsAncestor(t, Tasks.current()))
                     continue;
@@ -412,6 +426,7 @@ public class LocalEntityManager implements EntityManagerInternal {
                 if (!t.isDone()) {
                     try {
                         log.debug("Cancelling "+t+" on "+entity);
+                        tasksCancelled.add(t);
                         t.cancel(true);
                     } catch (Exception e) {
                         Exceptions.propagateIfFatal(e);
@@ -420,6 +435,27 @@ public class LocalEntityManager implements EntityManagerInternal {
                     }
                 }
             }
+            
+            if (timeleft!=null) {
+                Set<Task<?>> tasksIncomplete = MutableSet.of();
+                // go through all tasks, not just cancelled ones, in case there are previously
cancelled ones which are not complete
+                for (Task<?> t: managementContext.getExecutionContext(entity).getTasks())
{
+                    if (hasTaskAsAncestor(t, Tasks.current()))
+                        continue;
+                    if (!Tasks.blockUntilInternalTasksEnded(t, timeleft.getDurationRemaining()))
{
+                        tasksIncomplete.add(t);
+                    }
+                }
+                if (!tasksIncomplete.isEmpty()) {
+                    log.warn("Incomplete tasks when stopping "+entity+": "+tasksIncomplete);
+                }
+                if (log.isTraceEnabled())
+                    log.trace("Cancelled "+tasksCancelled+" tasks for "+entity+", with "+
+                            timeleft.getDurationRemaining()+" remaining (of "+timeout+"):
"+tasksCancelled);
+            } else {
+                if (log.isTraceEnabled())
+                    log.trace("Cancelled "+tasksCancelled+" tasks for "+entity+": "+tasksCancelled);
+            }
         } catch (Exception e) {
             Exceptions.propagateIfFatal(e);
             log.warn("Error inspecting tasks to cancel on unmanagement: "+e, e);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
index e6d6dcf..564e39b 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalLocationManager.java
@@ -258,7 +258,7 @@ public class LocalLocationManager implements LocationManagerInternal {
         unmanage(loc, mode, false);
     }
     
-    private void unmanage(final Location loc, ManagementTransitionMode mode, boolean hasBeenReplaced)
{
+    private void unmanage(final Location loc, final ManagementTransitionMode mode, boolean
hasBeenReplaced) {
         if (shouldSkipUnmanagement(loc)) return;
 
         if (hasBeenReplaced) {
@@ -276,7 +276,7 @@ public class LocalLocationManager implements LocationManagerInternal {
 
         } else if (mode==ManagementTransitionMode.REBINDING_DESTROYED || mode==ManagementTransitionMode.REBINDING_NO_LONGER_PRIMARY)
{
             // we are unmanaging an instance whose primary management is elsewhere (either
we were secondary, or we are being demoted)
-            unmanageNonRecursive(loc);
+            unmanageNonRecursive(loc, mode);
             managementContext.getRebindManager().getChangeListener().onUnmanaged(loc);
             if (managementContext.gc != null) managementContext.gc.onUnmanaged(loc);
             
@@ -288,7 +288,7 @@ public class LocalLocationManager implements LocationManagerInternal {
             // Need to store all child entities as onManagementStopping removes a child from
the parent entity
             recursively(loc, new Predicate<AbstractLocation>() { public boolean apply(AbstractLocation
it) {
                 if (shouldSkipUnmanagement(it)) return false;
-                boolean result = unmanageNonRecursive(it);
+                boolean result = unmanageNonRecursive(it, mode);
                 if (result) {
                     ManagementTransitionMode mode = getLastManagementTransitionMode(it.getId());
                     if (mode==null) {
@@ -373,8 +373,14 @@ public class LocalLocationManager implements LocationManagerInternal
{
      * Should ensure that the location is no longer managed anywhere, remove from all lists.
      * Returns true if the location has been removed from management; if it was not previously
managed (anything else throws exception) 
      */
-    private synchronized boolean unmanageNonRecursive(Location loc) {
-        ((AbstractLocation)loc).setParent(null, false);
+    private synchronized boolean unmanageNonRecursive(Location loc, ManagementTransitionMode
mode) {
+        if (mode==ManagementTransitionMode.DESTROYING) {
+            ((AbstractLocation)loc).setParent(null, true);
+        } else {
+            // if not destroying, don't change the parent's children list
+            ((AbstractLocation)loc).setParent(null, false);
+        }
+        
         Object old = locationsById.remove(loc.getId());
         locationTypes.remove(loc.getId());
         locationModesById.remove(loc.getId());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/management/internal/LocalSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalSubscriptionManager.java
b/core/src/main/java/brooklyn/management/internal/LocalSubscriptionManager.java
index 83cec75..fb11801 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalSubscriptionManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalSubscriptionManager.java
@@ -179,7 +179,17 @@ public class LocalSubscriptionManager extends AbstractSubscriptionManager
{
                 if (s.eventFilter!=null && !s.eventFilter.apply(event))
                     continue;
                 final Subscription sAtClosureCreation = s;
-                em.submit(mapOf("tag", s.subscriberExecutionManagerTag), new Runnable() {
+                
+//                Set<Object> tags = MutableSet.of();
+//                if (s.subscriberExecutionManagerTag!=null) tags.add(s.subscriberExecutionManagerTag);
+//                if (event.getSource()!=null) tags.add(BrooklynTaskTags.tagForContextEntity(event.getSource()));
+//                Map<String, Object> tagsMap = mapOf("tags", (Object)tags);
+                // use code above, instead of line below, if we want subscription deliveries
associated with the entity;
+                // that will cause them to be cancelled when the entity is unmanaged
+                // (not sure that is useful, and likely NOT worth the expense, but it might
be...) -Alex Oct 2014
+                Map<String, Object> tagsMap = mapOf("tag", s.subscriberExecutionManagerTag);
+                
+                em.submit(tagsMap, new Runnable() {
                     @Override
                     public String toString() {
                         return "LSM.publish("+event+")";

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java b/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
index 98eb7be..00c6c9f 100644
--- a/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
+++ b/core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
@@ -97,9 +97,9 @@ public class BasicExecutionManager implements ExecutionManager {
 
     //access to this field AND to members in this field is synchronized, 
     //to allow us to preserve order while guaranteeing thread-safe
-    //(but more testing is needed before we are sure it is thread-safe!)
-    //synch blocks are as finely grained as possible for efficiency
-    //Not using a CopyOnWriteArraySet for each, because profiling showed this being a massive
perf bottleneck.
+    //(but more testing is needed before we are completely sure it is thread-safe!)
+    //synch blocks are as finely grained as possible for efficiency;
+    //NB CopyOnWriteArraySet is a perf bottleneck, and the simple map makes it easier to
remove when a tag is empty
     private Map<Object,Set<Task<?>>> tasksByTag = new HashMap<Object,Set<Task<?>>>();
     
     private ConcurrentMap<String,Task<?>> tasksById = new ConcurrentHashMap<String,Task<?>>();
@@ -217,7 +217,7 @@ public class BasicExecutionManager implements ExecutionManager {
         Task<?> removed = tasksById.remove(task.getId());
         incompleteTaskIds.remove(task.getId());
         if (removed!=null && removed.isSubmitted() && !removed.isDone())
{
-            log.warn("Deleting submitted but incomplete task (cancel it first): "+removed);
+            log.warn("Deleting submitted task before completion: "+removed+"; this task will
continue to run in the background outwith "+this+", but perhaps it should have been cancelled?");
         }
         return removed != null;
     }
@@ -591,13 +591,13 @@ public class BasicExecutionManager implements ExecutionManager {
     }
     
     protected void beforeSubmitScheduledTaskAllIterations(Map<?,?> flags, Task<?>
task) {
-        beforeSubmit(flags, task);
+        internalBeforeSubmit(flags, task);
     }
     protected void beforeSubmitAtomicTask(Map<?,?> flags, Task<?> task) {
-        beforeSubmit(flags, task);
+        internalBeforeSubmit(flags, task);
     }
     /** invoked when a task is submitted */
-    protected void beforeSubmit(Map<?,?> flags, Task<?> task) {
+    protected void internalBeforeSubmit(Map<?,?> flags, Task<?> task) {
         incompleteTaskIds.put(task.getId(), task.getId());
         
         Task<?> currentTask = Tasks.current();
@@ -613,15 +613,15 @@ public class BasicExecutionManager implements ExecutionManager {
     }
 
     protected void beforeStartScheduledTaskSubmissionIteration(Map<?,?> flags, Task<?>
task) {
-        beforeStart(flags, task);
+        internalBeforeStart(flags, task);
     }
     protected void beforeStartAtomicTask(Map<?,?> flags, Task<?> task) {
-        beforeStart(flags, task);
+        internalBeforeStart(flags, task);
     }
     
     /** invoked in a task's thread when a task is starting to run (may be some time after
submitted), 
      * but before doing any of the task's work, so that we can update bookkeeping and notify
callbacks */
-    protected void beforeStart(Map<?,?> flags, Task<?> task) {
+    protected void internalBeforeStart(Map<?,?> flags, Task<?> task) {
         activeTaskCount.incrementAndGet();
         
         //set thread _before_ start time, so we won't get a null thread when there is a start-time
@@ -642,23 +642,23 @@ public class BasicExecutionManager implements ExecutionManager {
 
     /** normally (if not interrupted) called once for each call to {@link #beforeSubmitScheduledTaskAllIterations(Map,
Task)} */
     protected void afterEndScheduledTaskAllIterations(Map<?,?> flags, Task<?>
task) {
-        _afterEnd(flags, task, false, true);
+        internalAfterEnd(flags, task, false, true);
     }
     /** called once for each call to {@link #beforeStartScheduledTaskSubmissionIteration(Map,
Task)},
      * with a per-iteration task generated by the surrounding scheduled task */
     protected void afterEndScheduledTaskSubmissionIteration(Map<?,?> flags, Task<?>
scheduledTask, Task<?> taskIteration) {
-        _afterEnd(flags, scheduledTask, true, false);
+        internalAfterEnd(flags, scheduledTask, true, false);
     }
     /** called once for each task on which {@link #beforeStartAtomicTask(Map, Task)} is invoked,
      * and normally (if not interrupted prior to start) 
      * called once for each task on which {@link #beforeSubmitAtomicTask(Map, Task)} */
     protected void afterEndAtomicTask(Map<?,?> flags, Task<?> task) {
-        _afterEnd(flags, task, true, true);
+        internalAfterEnd(flags, task, true, true);
     }
-    /** normally (if not interrupted) called once for each call to {@link #beforeSubmit(Map,
Task)},
+    /** normally (if not interrupted) called once for each call to {@link #internalBeforeSubmit(Map,
Task)},
      * and, for atomic tasks and scheduled-task submission iterations where 
-     * always called once if {@link #beforeStart(Map, Task)} is invoked and in the same thread
as that method */
-    protected void _afterEnd(Map<?,?> flags, Task<?> task, boolean startedInThisThread,
boolean isEndingAllIterations) {
+     * always called once if {@link #internalBeforeStart(Map, Task)} is invoked and in the
same thread as that method */
+    protected void internalAfterEnd(Map<?,?> flags, Task<?> task, boolean startedInThisThread,
boolean isEndingAllIterations) {
         if (log.isTraceEnabled()) log.trace(this+" afterEnd, task: "+task);
         if (startedInThisThread) {
             activeTaskCount.decrementAndGet();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
index 34942b6..756d549 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
@@ -50,6 +50,7 @@ import brooklyn.location.Location;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.management.Task;
+import brooklyn.test.Asserts;
 import brooklyn.test.EntityTestUtils;
 import brooklyn.test.entity.TestEntity;
 import brooklyn.test.entity.TestEntityImpl.TestEntityWithoutEnrichers;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
index 67989fd..3cb6896 100644
--- a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
@@ -586,7 +586,7 @@ public class HotStandbyTest {
         assertHotStandby(n1);
         // and it sees apps
         Assert.assertFalse(n1.mgmt.getApplications().isEmpty(), "n1 should have had apps
now");
-        Assert.assertFalse(n1.mgmt.getApplications().isEmpty(), "n1 should have had locations
now");
+        Assert.assertFalse(n1.mgmt.getLocationManager().getLocations().isEmpty(), "n1 should
have had locations now");
         // and if n2 is disabled, n1 promotes
         n2.ha.changeMode(HighAvailabilityMode.DISABLED);
         n1.ha.changeMode(HighAvailabilityMode.AUTO);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
index a3aa70c..5ca42ae 100644
--- a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
+++ b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
@@ -337,16 +337,27 @@ public class EntityExecutionManagerTest {
         
         BasicAttributeSensor<Object> byteArrayAttrib = new BasicAttributeSensor<Object>(Object.class,
"test.byteArray", "");
 
-        for (int i = 0; i < 200; i++) {
-            if (i<10 || i%10==0) LOG.info(JavaClassNames.niceClassAndMethod()+": iteration
"+i);
+        for (int i = 0; i < 1000; i++) {
+            if (i<100 && i%10==0 || i%100==0) LOG.info(JavaClassNames.niceClassAndMethod()+":
iteration "+i);
             try {
                 LOG.debug(JavaClassNames.niceClassAndMethod()+": iteration="+i);
                 TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
                 entity.setAttribute(byteArrayAttrib, new BigObject(10*1000*1000));
                 entity.invoke(TestEntity.MY_EFFECTOR, ImmutableMap.<String,Object>of()).get();
-                Entities.destroy(entity);
+                
+                // we get exceptions because tasks are still trying to publish after deployment;
+                // this should prevent them
+//                ((LocalEntityManager)app.getManagementContext().getEntityManager()).stopTasks(entity,
Duration.ONE_SECOND);
+//                Entities.destroy(entity);
+                
+                // alternatively if we 'unmanage' instead of destroy, there are usually not
errors
+                // (the errors come from the node transitioning to a 'stopping' state on
destroy, 
+                // and publishing lots of info then)
+                Entities.unmanage(entity);
+                
                 forceGc();
-                System.gc(); System.gc();
+                // previously we did an extra GC but it was crazy slow, shouldn't be needed
+//                System.gc(); System.gc();
             } catch (OutOfMemoryError e) {
                 LOG.warn(JavaClassNames.niceClassAndMethod()+": OOME at iteration="+i);
                 ExecutionManager em = app.getManagementContext().getExecutionManager();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
index b704b58..364ef47 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
@@ -78,7 +78,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp
{
         return true;
     }
     
-    @BeforeMethod(groups = "Integration")
+    @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
         warUrl = getClass().getClassLoader().getResource("hello-world.war");
@@ -86,11 +86,12 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp
{
         executor = Executors.newCachedThreadPool();
     }
 
-    @AfterMethod(groups = "Integration", alwaysRun=true)
+    @AfterMethod(alwaysRun=true)
     public void tearDown() throws Exception {
         for (WebAppMonitor monitor : webAppMonitors) {
             monitor.terminate();
         }
+        webAppMonitors.clear();
         if (executor != null) executor.shutdownNow();
         super.tearDown();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
index a9508eb..39bcd2e 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
@@ -84,7 +84,7 @@ public class NginxRebindWithHaIntegrationTest extends RebindTestFixtureWithApp
{
         return true;
     }
     
-    @BeforeMethod(groups = "Integration")
+    @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
         warUrl = getClass().getClassLoader().getResource("hello-world.war");
@@ -97,17 +97,21 @@ public class NginxRebindWithHaIntegrationTest extends RebindTestFixtureWithApp
{
         BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY,
true);
     }
 
-    @AfterMethod(groups = "Integration", alwaysRun=true)
+    @AfterMethod(alwaysRun=true)
     public void tearDown() throws Exception {
-        if (feedRegistration!=null)
-            BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY,
feedRegistration);
-        
-        for (WebAppMonitor monitor : webAppMonitors) {
-            monitor.terminate();
+        try {
+            if (feedRegistration!=null)
+                BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_FEED_REGISTRATION_PROPERTY,
feedRegistration);
+
+            for (WebAppMonitor monitor : webAppMonitors) {
+                monitor.terminate();
+            }
+            webAppMonitors.clear();
+            if (executor != null) executor.shutdownNow();
+            super.tearDown();
+        } finally {
+            RecordingSshjTool.reset();
         }
-        if (executor != null) executor.shutdownNow();
-        super.tearDown();
-        RecordingSshjTool.reset();
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e1e0acf6/utils/common/src/main/java/brooklyn/test/Asserts.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/test/Asserts.java b/utils/common/src/main/java/brooklyn/test/Asserts.java
index d52c347..11bfa02 100644
--- a/utils/common/src/main/java/brooklyn/test/Asserts.java
+++ b/utils/common/src/main/java/brooklyn/test/Asserts.java
@@ -191,7 +191,7 @@ public class Asserts {
     }
     
     /**
-     * Asserts given callable succeeds in default duration.
+     * Asserts given callable succeeds (runs without failure) in default duration.
      * @see #DEFAULT_TIMEOUT
      */
     public static <T> T succeedsEventually(Callable<T> c) {


Mime
View raw message