/** * Registers the given location (and all its children) with the management context. * @throws IllegalStateException if the parent location is not already managed * * @since 0.6.0 (added only for backwards compatibility, where locations are being created directly; previously in {@link Entities}). * @deprecated in 0.6.0; use {@link LocationManager#createLocation(LocationSpec)} instead. */ @Deprecated public static void manage(Location loc, ManagementContext managementContext) { if (!managementContext.getLocationManager().isManaged(loc)) { log.warn("Deprecated use of unmanaged location ("+loc+"); will be managed automatically now but not supported in future versions"); // FIXME this occurs MOST OF THE TIME e.g. including BrooklynLauncher.location(locationString) // not sure what is the recommend way to convert from locationString to locationSpec, or the API we want to expose; // deprecating some of the LocationRegistry methods seems sensible? log.debug("Stack trace for location of: Deprecated use of unmanaged location; will be managed automatically now but not supported in future versions", new Exception("TRACE for: Deprecated use of unmanaged location")); managementContext.getLocationManager().manage(loc); } }
public static boolean isManaged(Location loc) { ManagementContext mgmt = ((LocationInternal)loc).getManagementContext(); return (mgmt != null) && mgmt.isRunning() && mgmt.getLocationManager().isManaged(loc); }
@Override public void deleteLocation() { DockerContainerLocation location = getDynamicLocation(); if (location != null) { try { location.close(); } catch (IOException ioe) { LOG.debug("Error closing container location", ioe); } LocationManager mgr = getManagementContext().getLocationManager(); if (mgr.isManaged(location)) { mgr.unmanage(location); } } sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); }
@Override public void deleteLocation() { MarathonTaskLocation location = getDynamicLocation(); if (location != null) { LocationManager mgr = getManagementContext().getLocationManager(); if (mgr.isManaged(location)) { mgr.unmanage(location); } } sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); }
@Override public void deleteLocation() { LocationManager mgr = getManagementContext().getLocationManager(); ServerPoolLocation location = getDynamicLocation(); if (location != null && mgr.isManaged(location)) { LOG.debug("{} deleting and unmanaging location {}", this, location); location.deregister(); mgr.unmanage(location); } sensors().set(LOCATION_SPEC, null); sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); }
assertExpectedTargetsEventually(members); Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations()))); rebind(); Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations())), "location not managed after rebind"); Assert.assertTrue(mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations()))); log.info("resized "+cluster+" ("+result+") - "+cluster.getChildren()); HashSet<StubAppServer> newEntities = Sets.newHashSet(Iterables.filter(cluster.getChildren(), StubAppServer.class));
if (!getManagementContext().getLocationManager().isManaged(child)) { Locations.manage(child, getManagementContext());
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); EntitySpec<StubAppServer> serverSpec = EntitySpec.create(StubAppServer.class); cluster = app().createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure(DynamicCluster.INITIAL_SIZE, initialClusterSize) .configure(DynamicCluster.MEMBER_SPEC, serverSpec)); urlMapping = app().createAndManageChild(EntitySpec.create(UrlMapping.class) .configure("domain", "localhost") .configure("target", cluster)); app().start( ImmutableList.of( mgmt().getLocationManager().createLocation( LocationSpec.create(LocalhostMachineProvisioningLocation.class)) )); log.info("app's location managed: "+mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(app().getLocations()))); log.info("clusters's location managed: "+mgmt().getLocationManager().isManaged(Iterables.getOnlyElement(cluster.getLocations()))); }
@Override public void deleteLocation() { StubContainerLocation location = getDynamicLocation(); if (location != null) { try { location.close(); } catch (IOException ioe) { LOG.debug("Error closing container location", ioe); } LocationManager mgr = getManagementContext().getLocationManager(); if (mgr.isManaged(location)) { mgr.unmanage(location); } } sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); } }