Github user alasdairhodge commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/548#discussion_r99079636
--- Diff:
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
---
@@ -475,6 +483,19 @@ private void unmanage(final Entity e,
ManagementTransitionMode mode, boolean has
entityModesById.remove(e.getId());
}
+ private void pruneOrphanedLocations(Entity unmanagedEntity) {
+ Set<Location> orphanLocations =
MutableSet.copyOf(unmanagedEntity.getLocations());
+ for (Entity e : getEntities()) {
+ if (e == unmanagedEntity)
+ continue;
+ orphanLocations.removeAll(e.getLocations());
+ }
+ LocationManager lm = managementContext.getLocationManager();
+ for (Location l : orphanLocations) {
+ lm.unmanage(l);
+ }
+ }
--- End diff --
Perhaps this method should be moved onto `ManagementContextInternal` and
broadened to GC orphans of all types? As it stands, we're coupling
`LocalEntityManger` to `(Local)LocationManager`.
---
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.
---