public LocationRegistry getLocationRegistry() { return mgmt.getLocationRegistry(); }
public LocationRegistry getLocationRegistry() { return mgmt.getLocationRegistry(); }
@VisibleForTesting public static void setupLocationRegistryForTesting(ManagementContext mgmt) { // ensure localhost is added (even on windows) LocationDefinition l = mgmt.getLocationRegistry().getDefinedLocationByName("localhost"); if (l==null) mgmt.getLocationRegistry().updateDefinedLocation( ((BasicLocationRegistry)mgmt.getLocationRegistry()).localhost(Identifiers.makeRandomId(8))); ((BasicLocationRegistry)mgmt.getLocationRegistry()).disablePersistence(); }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public synchronized T obtain() throws NoMachinesAvailableException { if (singleLocation == null) { if (provisioningLocation == null) { provisioningLocation = (MachineProvisioningLocation) getManagementContext().getLocationRegistry().resolve( location, locationFlags); } singleLocation = provisioningLocation.obtain(ImmutableMap.of()); inUse.add(singleLocation); } referenceCount++; return singleLocation; }
@Override public String addRegion(String location) { Preconditions.checkNotNull(location, "location"); Location l = getManagementContext().getLocationRegistry().resolve(location); addLocations(Arrays.asList(l)); Entity e = addCluster(l); ((EntityInternal)e).addLocations(Arrays.asList(l)); if (e instanceof Startable) { Task<?> task = e.invoke(Startable.START, ImmutableMap.of("locations", ImmutableList.of(l))); task.getUnchecked(); } return e.getId(); }
protected Location newLocationFromString(String spec, brooklyn.location.LocationRegistry registry, Map properties, Map locationFlags) { Matcher matcher = PATTERN.matcher(spec); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid location '" + spec + "'; must specify something like single(named:foo)"); } String namedLocation = (String) locationFlags.get("named"); String args = matcher.group(2); Map<String,?> locationArgs = KeyValueParser.parseMap(args); Map<String, Object> filteredProperties = new LocationPropertiesFromBrooklynProperties().getLocationProperties(null, namedLocation, properties); MutableMap<String, Object> flags = MutableMap.<String, Object>builder() .putAll(filteredProperties) .putAll(locationFlags) .removeAll("named") .putAll(locationArgs).build(); if (locationArgs.get("target") == null) { throw new IllegalArgumentException("target must be specified in single-machine spec"); } String target = locationArgs.get("target").toString(); locationArgs.remove("target"); if (!managementContext.getLocationRegistry().canResolve(target)) { throw new IllegalArgumentException("Invalid target location '" + target + "'; must be resolvable location"); } return managementContext.getLocationManager().createLocation(LocationSpec.create(SingleMachineProvisioningLocation.class) .configure("location", target) .configure("locationFlags", flags)); }
protected FixedListMachineProvisioningLocation<SshMachineLocation> newLocationFromString(String spec, brooklyn.location.LocationRegistry registry, Map properties, Map locationFlags) { Matcher matcher = PATTERN.matcher(spec); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid location '" + spec + "'; must specify something like host:(\"1.1.1.1\")"); } String namedLocation = (String) locationFlags.get("named"); Map<String, Object> filteredProperties = new LocationPropertiesFromBrooklynProperties().getLocationProperties(null, namedLocation, properties); MutableMap<String, Object> flags = MutableMap.<String, Object>builder().putAll(filteredProperties).putAll(locationFlags).removeAll("named").build(); String args = matcher.group(2); String target = "byon:(hosts=" + args + ")"; if (!managementContext.getLocationRegistry().canResolve(target)) { throw new IllegalArgumentException("Invalid target location '" + target + "'; must be resolvable location"); } return managementContext.getLocationManager().createLocation(LocationSpec.create(SingleMachineProvisioningLocation.class) .configure("location", target) .configure("locationFlags", flags)); }
locations.addAll(managementContext.getLocationRegistry().resolve(locationSpecs));