public class MultiLocation<T extends MachineLocation> extends AbstractLocation implements MachineProvisioningLocation<T>
AvailabilityZoneExtension
-aware entity
is used, it may stripe across each of the locations. See notes at AvailabilityZoneExtension
.Modifier and Type | Class and Description |
---|---|
static class |
MultiLocation.AvailabilityZoneExtensionImpl |
AbstractLocation.BasicSubscriptionSupport
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
Modifier and Type | Field and Description |
---|---|
static ConfigKey<java.util.List<LocationSpec<?>>> |
SUB_LOCATION_SPECS
The subLocationSpecs allows
MultiLocationResolver to work with just LocationSpecs, rather than
having to instantiate the sub-locations immediately (which would be bad, because the caller
might not use the spec and thus might not unmanage the sub-location instances). |
static ConfigKey<java.util.List<MachineProvisioningLocation<?>>> |
SUB_LOCATIONS |
PARENT_LOCATION, TEMPORARY_LOCATION
FINAL_SPEC, NAMED_SPEC_NAME, ORIGINAL_SPEC
Constructor and Description |
---|
MultiLocation() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getProvisioningFlags(java.util.Collection<java.lang.String> tags)
Gets flags, suitable as an argument to
MachineProvisioningLocation.obtain(Map) . |
java.util.List<MachineProvisioningLocation<?>> |
getSubLocations() |
void |
init()
Called by framework (in new-style instances where spec was used) after configuring etc,
but before a reference to this instance is shared.
|
MachineProvisioningLocation<T> |
newSubLocation(java.util.Map<?,?> newFlags)
Creates a new location of the same type, but with additional creation instructions in the form of flags,
e.g.
|
T |
obtain() |
T |
obtain(java.util.Map<?,?> flags)
finds (creates) and returns a
MachineLocation ;
this always tries the first sub-location, moving on the second and subsequent if the first throws NoMachinesAvailableException . |
void |
release(T machine)
Release a previously-obtained machine.
|
addChild, addExtension, config, configure, containsLocation, equals, getChildren, getConfig, getConfig, getDisplayName, getExtension, getHostGeoInfo, getLocationTypeInternal, getParent, getRebindSupport, hasExtension, hashCode, isManaged, onManagementStarted, onManagementStopped, rebind, relations, removeChild, setDisplayName, setHostGeoInfo, setManagementContext, setParent, setParent, subscriptions, toMetadataRecord, toString, toVerboseString
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, getManagementContext, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId, tags
containsLocation, getChildren, getConfig, getDisplayName, getExtension, getId, getParent, hasExtension, relations, setParent, toVerboseString
getCatalogItemId, getCatalogItemIdSearchPath, subscriptions, tags
config, getConfig
getManagementContext
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
public static final ConfigKey<java.util.List<LocationSpec<?>>> SUB_LOCATION_SPECS
MultiLocationResolver
to work with just LocationSpecs, rather than
having to instantiate the sub-locations immediately (which would be bad, because the caller
might not use the spec and thus might not unmanage the sub-location instances).
We clear the subLocationSpecs in init, so they will never be persisted. This will help with
backwards compatibility if we change how this is done.
By the end of init(), the SUB_LOCATIONS
will contain the full list of locations; it
will never contain a LocationSpec
.public static final ConfigKey<java.util.List<MachineProvisioningLocation<?>>> SUB_LOCATIONS
public void init()
AbstractBrooklynObject
To preserve backwards compatibility for if the instance is constructed directly, one can call the code below, but that means it will be called after references to this policy have been shared with other entities.
if (isLegacyConstruction()) {
init();
}
init
in class AbstractLocation
public T obtain() throws NoMachinesAvailableException
NoMachinesAvailableException
public T obtain(java.util.Map<?,?> flags) throws NoMachinesAvailableException
MachineLocation
;
this always tries the first sub-location, moving on the second and subsequent if the first throws NoMachinesAvailableException
.
(if you want striping across locations, see notes in AvailabilityZoneExtension
.)obtain
in interface MachineProvisioningLocation<T extends MachineLocation>
obtain
in interface ProvisioningLocation<T extends MachineLocation>
flags
- Details of the desired machine (e.g. image, size, open ports, etc; some flag support is limited to selected providers).
"callerContext" can be specified to have custom logging and error messages (useful if starting machines in parallel)NoMachinesAvailableException
- if there are no machines available in this location (or impls may return null, but that is discouraged)public java.util.List<MachineProvisioningLocation<?>> getSubLocations()
public MachineProvisioningLocation<T> newSubLocation(java.util.Map<?,?> newFlags)
MachineProvisioningLocation
Implementers who wish to subclass this provisioning location for additional functionality in a specific cloud can use the relevant implementation of this method as a guide.
newSubLocation
in interface MachineProvisioningLocation<T extends MachineLocation>
public void release(T machine)
MachineProvisioningLocation
release
in interface MachineProvisioningLocation<T extends MachineLocation>
release
in interface ProvisioningLocation<T extends MachineLocation>
machine
- a MachineLocation
previously obtained from a call to #obtain()
public java.util.Map<java.lang.String,java.lang.Object> getProvisioningFlags(java.util.Collection<java.lang.String> tags)
MachineProvisioningLocation
MachineProvisioningLocation.obtain(Map)
. The tags provided give
hints about the machine required. The provisioning-location could be configured to
understand those tags.
For example, an AWS-location could be configured to understand that a particular entity
type (e.g. "TomcatServer") requires a particular AMI in that region, so would return the
required image id.getProvisioningFlags
in interface MachineProvisioningLocation<T extends MachineLocation>