@Test public void testManaged() throws Exception { // TODO get exception in LocalhostMachineProvisioningLocation.removeChild because childLoc is "in use"; // this happens from the call to unmanage(loc), which first unmanaged the children. loc.release(childLoc); assertTrue(LocationPredicates.managed().apply(loc)); Locations.unmanage(loc); assertFalse(LocationPredicates.managed().apply(loc)); } }
protected JcloudsLocation replaceJcloudsLocation(String locationSpec) { if (machines != null && machines.size() > 0) { throw new IllegalStateException("Cannot replace jcloudsLocation after provisioning machine with old one"); } if (jcloudsLocation != null) { Locations.unmanage(jcloudsLocation); } jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged( locationSpec, jcloudsLocationConfig(ImmutableMap.<Object, Object>of( JcloudsLocationConfig.COMPUTE_SERVICE_REGISTRY, computeServiceRegistry, JcloudsLocationConfig.WAIT_FOR_SSHABLE, "false", JcloudsLocationConfig.POLL_FOR_FIRST_REACHABLE_ADDRESS, "false"))); return jcloudsLocation; }
private boolean isPidRunning(File pidFile) throws Exception { SshMachineLocation machine = loc.obtain(); try { int result = machine.execScript("check-pid", ImmutableList.of( "test -f "+pidFile+" || exit 1", "ps -p `cat "+pidFile+"`")); return result == 0; } finally { loc.release(machine); Locations.unmanage(machine); } }
@Override public void deleteLocation() { MarathonLocation location = getDynamicLocation(); if (location != null) { location.deregister(); Locations.unmanage(location); } sensors().set(LocationOwner.DYNAMIC_LOCATION, null); sensors().set(LocationOwner.LOCATION_NAME, null); }
@Override public void deleteLocation() { DockerLocation location = getDynamicLocation(); if (location != null) { location.deregister(); Locations.unmanage(location); } sensors().set(LocationOwner.DYNAMIC_LOCATION, null); sensors().set(LocationOwner.LOCATION_NAME, null); }
@Override public void deleteLocation() { DockerHostLocation loc = getDynamicLocation(); if (loc != null) { loc.deregister(); Locations.unmanage(loc); } sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); }
@Override public void deleteLocation() { MesosLocation location = getDynamicLocation(); if (location != null) { location.deregister(); Locations.unmanage(location); } sensors().set(LocationOwner.DYNAMIC_LOCATION, null); sensors().set(LocationOwner.LOCATION_NAME, null); }
@Override public void release(StubContainerLocation machine) { DynamicCluster cluster = dockerHost.getDockerContainerCluster(); StubContainer container = machine.getOwner(); if (cluster.removeMember(container)) { LOG.info("Docker Host {}: member {} released", dockerHost, machine); } else { LOG.warn("Docker Host {}: member {} not found for release", dockerHost, machine); } // Now close and unmange the container try { container.stop(); machine.close(); } catch (Exception e) { LOG.warn("Error stopping container: " + container, e); Exceptions.propagateIfFatal(e); } finally { Entities.unmanage(container); Locations.unmanage(machine); } }
@Test public void testExpungesOnEntityUnmanaged() throws Exception { Location loc = origManagementContext.getLocationRegistry().getLocationManaged("localhost"); TestEntity entity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class)); MyPolicy policy = entity.policies().add(PolicySpec.create(MyPolicy.class)); MyEnricher enricher = entity.enrichers().add(EnricherSpec.create(MyEnricher.class)); RebindTestUtils.waitForPersisted(origApp); Entities.unmanage(entity); Locations.unmanage(loc); RebindTestUtils.stopPersistence(origApp); BrooklynMementoManifest manifest = loadMementoManifest(); assertFalse(manifest.getEntityIdToManifest().containsKey(entity.getId())); assertFalse(manifest.getPolicyIdToType().containsKey(policy.getId())); assertFalse(manifest.getEnricherIdToType().containsKey(enricher.getId())); assertFalse(manifest.getLocationIdToType().containsKey(loc.getId())); }
@Override public void deleteLocation() { StubInfrastructureLocation location = getDynamicLocation(); if (location != null) { location.deregister(); Locations.unmanage(location); } sensors().set(LocationOwner.DYNAMIC_LOCATION, null); sensors().set(LocationOwner.LOCATION_NAME, null); }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); Locations.unmanage(machineWithThatConfig); } } }
private void assertReachability(boolean expectedReachable, SshMachineLocation machine, String addr, String msg) { SshMachineLocation tmpMachine = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machine.config().getBag().getAllConfig()) .configure("address", addr)); try { boolean sshable = tmpMachine.isSshable(); assertEquals(sshable, expectedReachable, addr+" not sshable; "+msg); } finally { Locations.unmanage(tmpMachine); } }
@Override public void deleteLocation() { StubHostLocation loc = (StubHostLocation) sensors().get(DYNAMIC_LOCATION); if (loc != null) { loc.deregister(); Locations.unmanage(loc); } sensors().set(DYNAMIC_LOCATION, null); sensors().set(LOCATION_NAME, null); } }
@Test public void testHandlesDanglingReferencesInLocationListSurroundingValidReference() throws Exception { SshMachineLocation todelete = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); SshMachineLocation loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); SshMachineLocation todelete2 = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); origApp.addLocations(ImmutableList.of(todelete, loc, todelete2)); Locations.unmanage(todelete); assertTransformIsNoop(); }
@Test public void testHandlesDanglingReference() throws Exception { SshMachineLocation todelete = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); SshMachineLocation loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); origApp.addLocations(ImmutableList.of(todelete)); origApp.sensors().set(Sensors.newSensor(Object.class, "mysensor"), loc); origApp.config().set(ConfigKeys.newConfigKey(Object.class, "myconfig"), loc); origApp.tags().addTag(loc); loc.config().set(ConfigKeys.newConfigKey(Object.class, "myconfig"), todelete); Locations.unmanage(todelete); assertFalse(getRawData().getLocations().containsKey(todelete.getId())); assertTransformIsNoop(); }