Github user bostko commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1124#discussion_r48979000
  
    --- Diff: 
brooklyn-server/core/src/main/java/org/apache/brooklyn/core/entity/AbstractApplication.java
 ---
    @@ -220,13 +221,37 @@ public void stop() {
                     //but that could be handled by the impl at management
                     //(keeping recently unmanaged things)  
                     //  however unmanaging must be done last, _after_ we stop 
children and set attributes 
    +                Location machineProvisioningLocation = 
Iterables.getFirst(getLocations(), null);
                     getEntityManager().unmanage(this);
    +                if (machineProvisioningLocation != null) {
    +                    
unmanageProvisionerIfNotUsed(machineProvisioningLocation);
    +                }
                 }
             }
     
             logApplicationLifecycle("Stopped");
         }
     
    +    //TODO Think of general approach for expunging location provisioners.
    +    // I left a code which could be a possible general approach. However 
it needs tests.
    +    protected boolean 
unmanageProvisionerIfNotUsed(/*MachineProvisioningLocation<MachineLocation>*/Location
 machineProvisioningLocation) {
    +        if (machineProvisioningLocation.getChildren().isEmpty()) {
    +            Entity parentEntity = getParent();
    +            if (parentEntity == null) {
    +                
getManagementContext().getLocationManager().unmanage(machineProvisioningLocation);
    --- End diff --
    
    For `MachineLocation` the entity is responsible for starting and managing 
the location
    and the entity is responsible for stopping the `MachineLocation` instances 
(see 
    
https://github.com/apache/incubator-brooklyn/blob/master/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java#L926
 ).
    
    Unlike the `MachineLocation` instance a `MachineProvisioningLocation` 
instance is created from `InternalEntityFactory.initEntityAndDescendants` when 
`entitySpec` is being processed
    and respective to that instead of putting the expunge in 
`MachineLifecycleEffectorTasks.suspendAnyProvisionedMachines` I putted it 
directly in the `AbstractApplication.stop`.
    
    Is there a case where the `MachineProvisioningLocation` instance could be 
owned by another application? Do we have cross application usage of 
`MachineProvisioningLocation` instances?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to