@SuppressWarnings({"rawtypes"}) @Test(dependsOnMethods = "testDeployApplication") public void testLocatedLocation() { log.info("starting testLocatedLocations"); testListApplications(); LocationInternal l = (LocationInternal) getManagementContext() .getApplications() .iterator() .next() .getLocations() .iterator() .next(); if (l.config().getLocalRaw(LocationConfigKeys.LATITUDE).isAbsent()) { log.info("Supplying fake locations for localhost because could not be autodetected"); ((AbstractLocation) l).setHostGeoInfo(new HostGeoInfo("localhost", "localhost", 50, 0)); } Map result = client().resource("/v1/locations/usage/LocatedLocations").get(Map.class); log.info("LOCATIONS: " + result); Assert.assertEquals(result.size(), 1); Map details = (Map) result.values().iterator().next(); assertEquals(details.get("leafEntityCount"), 2); }
public void setParentLocation(Location parent) { if (parent == this) { throw new IllegalArgumentException("Location cannot be its own parent: " + this); } if (parent == parentLocation) { return; // no-op; already have desired parent } if (parentLocation != null) { Location oldParent = parentLocation; parentLocation = null; ((AbstractLocation) oldParent).removeChildLocation(this); // FIXME Nasty cast } if (parent != null) { parentLocation = parent; ((AbstractLocation) parentLocation).addChildLocation(this); // FIXME Nasty cast } }
@Override public void init() { super.init(); Integer portStartingPoint; Object rawPort = getAllConfigBag().getStringKey(PORT_FORWARD_MANAGER_STARTING_PORT.getName()); if (rawPort != null) { portStartingPoint = getConfig(PORT_FORWARD_MANAGER_STARTING_PORT); } else { portStartingPoint = getManagementContext().getConfig().getConfig(PORT_FORWARD_MANAGER_STARTING_PORT); } portReserved.set(portStartingPoint); log.debug(this + " set initial port to " + portStartingPoint); }
@Override public void setParent(Location newParent) { if (newParent == this) { throw new IllegalArgumentException("Location cannot be its own parent: " + this); } if (newParent == parent.get()) { return; // no-op; already have desired parent } // TODO Should we support a location changing parent? The resulting unmanage/manage might cause // problems. if (parent.get() != null) { Location oldParent = parent.get(); parent.set(null); ((AbstractLocation) oldParent).removeChild(this); // FIXME Nasty cast } if (newParent != null) { parent.set(newParent); ((AbstractLocation) parent.get()).addChild(this); // FIXME Nasty cast } }