@Override public MesosLocation createLocation(Map<String, ?> flags) { String locationName = config().get(LOCATION_NAME); if (Strings.isBlank(locationName)) { String prefix = config().get(LOCATION_NAME_PREFIX); String suffix = config().get(LOCATION_NAME_SUFFIX); locationName = Joiner.on("-").skipNulls().join(prefix, getId(), suffix); } MesosLocation location = getManagementContext() .getLocationManager() .createLocation( LocationSpec.create(MesosLocation.class) .displayName("Mesos Cluster(" + getId() + ")") .configure(flags) .configure(DynamicLocation.OWNER, getProxy()) .configure("locationName", locationName)); LocationDefinition definition = location.register(); sensors().set(LocationOwner.LOCATION_SPEC, definition.getSpec()); sensors().set(LocationOwner.DYNAMIC_LOCATION, location); sensors().set(LocationOwner.LOCATION_NAME, locationName); LOG.info("New Mesos cluster location {} created for {}", location, this); return (MesosLocation) location; }
@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); }