Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master f3e0430a0 -> da38796a0


Destroys machine on expunge, even if stopped
Fixes an issue where stopping an entity (with
stopMachineMode of NEVER) and then attempting
to expunge the top level application would
unmanage the entity, but not destroy the VM


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

Branch: refs/heads/master
Commit: 8ef80c54bb70304ba08ed693b3c19088109d8997
Parents: f3e0430
Author: Martin Harris <[email protected]>
Authored: Mon Mar 16 14:02:53 2015 +0530
Committer: Martin Harris <[email protected]>
Committed: Mon Mar 16 14:02:53 2015 +0530

----------------------------------------------------------------------
 .../entity/software/MachineLifecycleEffectorTasks.java         | 6 +++---
 .../java/brooklyn/entity/basic/SoftwareProcessEntityTest.java  | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8ef80c54/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
 
b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index a4b3f5d..f1b0a67 100644
--- 
a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ 
b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -583,7 +583,7 @@ public abstract class MachineLifecycleEffectorTasks {
         }
 
         Task<StopMachineDetails<Integer>> stoppingMachine = null;
-        if (canStop(stopMachineMode, isEntityStopped)) {
+        if (canStop(stopMachineMode, sshMachine.isAbsent())) {
             // Release this machine (even if error trying to stop process - we 
rethrow that after)
             stoppingMachine = DynamicTasks.queue("stopping (machine)", new 
Callable<StopMachineDetails<Integer>>() {
                 public StopMachineDetails<Integer> call() {
@@ -639,9 +639,9 @@ public abstract class MachineLifecycleEffectorTasks {
         if (log.isDebugEnabled()) log.debug("Stopped software process entity 
"+entity());
     }
 
-    protected static boolean canStop(StopMode stopMode, boolean 
isEntityStopped) {
+    protected static boolean canStop(StopMode stopMode, boolean 
isTargetStopped) {
         return stopMode == StopMode.ALWAYS ||
-                stopMode == StopMode.IF_NOT_STOPPED && !isEntityStopped;
+                stopMode == StopMode.IF_NOT_STOPPED && !isTargetStopped;
     }
 
     private void checkCompatibleMachineModes(Boolean isStopMachine, boolean 
hasStopMachineMode, StopMode stopMachineMode) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8ef80c54/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
 
b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
index 81dd571..c503b84 100644
--- 
a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
+++ 
b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
@@ -28,7 +28,6 @@ import 
brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters.StopMode;
 import brooklyn.entity.effector.Effectors;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.proxying.ImplementedBy;
-import brooklyn.entity.software.MachineLifecycleEffectorTasks;
 import brooklyn.entity.software.MachineLifecycleEffectorTasksTest;
 import brooklyn.entity.trait.Startable;
 import brooklyn.location.Location;
@@ -328,7 +327,7 @@ public class SoftwareProcessEntityTest extends 
BrooklynAppUnitTestSupport {
         } else {
             assertTrue(d.events.isEmpty());
         }
-        if (MachineLifecycleEffectorTasksTest.canStop(stopMachineMode, 
isEntityStopped)) {
+        if (MachineLifecycleEffectorTasksTest.canStop(stopMachineMode, machine 
== null)) {
             assertTrue(entity.getLocations().isEmpty());
             assertTrue(l.getAvailable().contains(machine));
         } else {

Reply via email to