public abstract class AbstractCloudMachineNamer extends java.lang.Object implements CloudMachineNamer
CloudMachineNamer
,
leaving just one method -- #generateNewIdOfLength(int)
--
for subclasses to provide.
CloudLocationConfig.VM_NAME_MAX_LENGTH
is used to find the VM length,
unless getCustomMaxNameLength(ConfigBag)
is overridden or
setDefaultMachineNameMaxLength(int)
invoked on the instance supplied.
Constructor and Description |
---|
AbstractCloudMachineNamer() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generateNewGroupId(ConfigBag setup)
Generate a name stem for a group of machines, based on context.
|
java.lang.String |
generateNewMachineUniqueName(ConfigBag setup)
Generate a name for a new machine, based on context.
|
java.lang.String |
generateNewMachineUniqueNameFromGroupId(ConfigBag setup,
java.lang.String groupId)
Generate a unique name from the given name stem.
|
java.lang.Integer |
getCustomMaxNameLength(ConfigBag setup)
Method for overriding to provide custom logic when an explicit config key is not set for the machine length.
|
int |
getLengthForMachineUniqueNameSalt(ConfigBag setup,
boolean includeSeparator) |
int |
getMaxNameLength(ConfigBag setup)
Returns the max length of a VM name for the cloud specified in setup;
this value is typically decremented by 9 to make room for jclouds labels;
delegates to
#getCustomMaxNameLength() when
CloudLocationConfig.VM_NAME_MAX_LENGTH is not set |
static java.lang.String |
sanitize(java.lang.String s) |
AbstractCloudMachineNamer |
setDefaultMachineNameMaxLength(int defaultMaxLength) |
AbstractCloudMachineNamer |
setDefaultMachineNameSeparatorAndSaltLength(java.lang.String separator,
int defaultMachineUniqueNameSaltLength)
Number of chars to use or reserve for the machine identifier when constructing a group identifier;
jclouds for instance uses "-" plus 8
|
public java.lang.String generateNewMachineUniqueName(ConfigBag setup)
CloudMachineNamer
The name should normally be unique, as a context might produce multiple machines, for example basing it partially on information from the context but also including some random salt.
generateNewMachineUniqueName
in interface CloudMachineNamer
public java.lang.String generateNewMachineUniqueNameFromGroupId(ConfigBag setup, java.lang.String groupId)
CloudMachineNamer
The name stem is normally based on context information so the usual
function of this method is to apply a suffix which helps to uniquely distinguish between machines
in cases where the same name stem (#generateNewGroupId()
) is used for multiple machines.
generateNewMachineUniqueNameFromGroupId
in interface CloudMachineNamer
public java.lang.String generateNewGroupId(ConfigBag setup)
CloudMachineNamer
The name does not need to be unique, as uniqueness will be applied by #generateNewMachineUniqueNameFromGroupId(String)
.
generateNewGroupId
in interface CloudMachineNamer
public int getMaxNameLength(ConfigBag setup)
#getCustomMaxNameLength()
when
CloudLocationConfig.VM_NAME_MAX_LENGTH
is not setpublic int getLengthForMachineUniqueNameSalt(ConfigBag setup, boolean includeSeparator)
public AbstractCloudMachineNamer setDefaultMachineNameMaxLength(int defaultMaxLength)
public AbstractCloudMachineNamer setDefaultMachineNameSeparatorAndSaltLength(java.lang.String separator, int defaultMachineUniqueNameSaltLength)
public java.lang.Integer getCustomMaxNameLength(ConfigBag setup)
@Beta public static java.lang.String sanitize(java.lang.String s)