@Override public boolean apply(@Nullable Location input) { return (input != null) && Locations.isManaged(input); } };
protected void assertNotYetManaged() { if (!inConstruction && Locations.isManaged(this)) { LOG.warn("Configuration being made to {} after deployment; may not be supported in future versions", this); } //throw new IllegalStateException("Cannot set configuration "+key+" on active location "+this) }
@Override public boolean apply(@Nullable Location input) { return (input != null) && Locations.isManaged(input); } }
public static void unmanage(Location loc) { if (isManaged(loc)) { ManagementContext mgmt = ((LocationInternal)loc).getManagementContext(); mgmt.getLocationManager().unmanage(loc); } }
protected void releaseMachine(JcloudsMachineLocation machine) { if (!Locations.isManaged(machine)) return; machines.remove(machine); machine.getParent().release(machine); }
public boolean removeChild(Location child) { boolean removed; synchronized (children) { removed = children.remove(child); } if (removed) { if (child instanceof Closeable) { Streams.closeQuietly((Closeable)child); } child.setParent(null); if (isManaged() && Locations.isManaged(child)) { // This is called as part of child's LocalLocationManager.unmanage; don't try to // unmanage it yet again as then would get a log.warn! getManagementContext().getLocationManager().unmanage(child); } } onChanged(); return removed; }
@Test public void testCreateAndReleaseDirectly() throws Exception { StubInfrastructure infra = mgmt.getEntityManager().createEntity(EntitySpec.create(StubInfrastructure.class) .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, shouldSkipOnBoxBaseDirResolution())); infra.start(ImmutableList.of(loc)); StubInfrastructureLocation loc = infra.getDynamicLocation(); MachineLocation machine = loc.obtain(ImmutableMap.of()); StubHost host = (StubHost) Iterables.getOnlyElement(infra.getStubHostCluster().getMembers()); StubHostLocation hostLoc = host.getDynamicLocation(); StubContainer container = (StubContainer) Iterables.getOnlyElement(host.getDockerContainerCluster().getMembers()); StubContainerLocation containerLoc = container.getDynamicLocation(); assertEquals(containerLoc, machine); assertEquals(Iterables.getOnlyElement(hostLoc.getChildren()), machine); loc.release(machine); assertFalse(Entities.isManaged(container)); assertFalse(Locations.isManaged(containerLoc)); }
if (Locations.isManaged(loc)) {
assertFalse(Locations.isManaged(containerLoc));
assertFalse(Locations.isManaged(containerLoc));
assertFalse(Locations.isManaged(containerLoc));