public class ClusterDescription extends Object implements Cloneable
info
and statistics maps contain information about the cluster.
As a wire format it is less efficient in both xfer and ser/deser than
a binary format, but by having one unified format for wire and persistence,
the code paths are simplified.
This was the original single-file specification/model used in the Hoya
precursor to Slider. Its now retained primarily as a way to publish
the current state of the application, or at least a fraction thereof ...
the larger set of information from the REST API is beyond the scope of
this structure.| Modifier and Type | Field and Description |
|---|---|
Map<String,String> |
clientProperties
List of key-value pairs to add to a client config to set up the client
|
long |
createTime
When was the cluster specification created?
This is not the time a cluster was thawed; that will
be in the
info section. |
String |
dataPath
This is where the data goes
|
String |
generatedConfigurationPath
URL path to the generated configuration
|
Map<String,String> |
info
cluster information
This is only valid when querying the cluster status.
|
Map<String,List<String>> |
instances
Instances: role->count
|
ApplicationLivenessInformation |
liveness
Liveness information; the same as returned
on the
live/liveness/ URL |
protected static org.slf4j.Logger |
log |
String |
name
Name of the cluster
|
Map<String,String> |
options
cluster-specific options -to control both
the Slider AM and the application that it deploys
|
String |
originConfigurationPath
URL path to the original configuration
files; these are re-read when
restoring a cluster
|
Map<String,Map<String,String>> |
roles
Role options,
role -> option -> value
|
int |
state
State of the cluster
|
static int |
STATE_CREATED
Cluster created: 2
|
static int |
STATE_DESTROYED
destroyed
|
static int |
STATE_INCOMPLETE
Specification is incomplete & cannot
be used: 0
|
static int |
STATE_LIVE
Live: 3
|
static int |
STATE_STOPPED
Stopped
|
static int |
STATE_SUBMITTED
Spec has been submitted: 1
|
Map<String,Map<String,Integer>> |
statistics
Statistics.
|
Map<String,Object> |
status
Status information
|
String |
type
Type of cluster
|
long |
updateTime
When was the cluster specification last updated
|
String |
version
version counter
|
| Constructor and Description |
|---|
ClusterDescription()
Creator.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Shallow clone
|
static ClusterDescription |
copy(ClusterDescription source)
Make a deep copy of the class
|
ClusterDescription |
deepClone()
A deep clone of the spec.
|
static ClusterDescription |
fromFile(File jsonFile)
Convert from a JSON file
|
static ClusterDescription |
fromJson(String json)
Convert from JSON
|
static ClusterDescription |
fromStream(InputStream is)
Convert from input stream
|
String |
getApplicationHome()
HBase home: if non-empty defines where a copy of HBase is preinstalled
|
String |
getImagePath()
The path in HDFS where the HBase image is
|
String |
getInfo(String key)
Get an information string.
|
boolean |
getInfoBool(String key)
Get an information string.
|
String |
getMandatoryOption(String key)
Get a cluster option or value
|
Map<String,String> |
getMandatoryRole(String role)
Get a role whose presence is mandatory
|
String |
getMandatoryRoleOpt(String role,
String option)
Get a mandatory role option
|
int |
getMandatoryRoleOptInt(String role,
String option)
Get a mandatory integer role option
|
String |
getOption(String key,
String defVal)
Get a cluster option or value
|
boolean |
getOptionBool(String option,
boolean defVal)
Get an option as a boolean.
|
int |
getOptionInt(String option,
int defVal)
Get an integer option; use
Integer.decode(String) so as to take hex
oct and bin values too. |
Map<String,String> |
getOrAddRole(String role)
Get a role -adding it to the roleopts map if
none with that name exists
|
Map<String,String> |
getRole(String role)
look up a role and return its options
|
Set<String> |
getRoleNames() |
String |
getRoleOpt(String role,
String option,
String defVal)
Get a role option
|
int |
getRoleOptInt(String role,
String option,
int defVal)
Get an integer role option; use
Integer.decode(String) so as to take hex
oct and bin values too. |
long |
getRoleOptLong(String role,
String option,
long defVal)
Get an integer role option; use
Integer.decode(String) so as to take hex
oct and bin values too. |
int |
getRoleResourceRequirement(String role,
String option,
int defVal,
int maxVal)
Get the value of a role requirement (cores, RAM, etc).
|
String |
getZkHosts() |
String |
getZkPath() |
boolean |
isImagePathSet()
Query for the image path being set (non null/non empty)
|
static ClusterDescription |
load(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
Load from the filesystem
|
void |
save(File file)
Save a cluster description to the local filesystem
|
void |
save(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
boolean overwrite)
Save a cluster description to a hadoop filesystem
|
void |
setApplicationHome(String applicationHome) |
void |
setImagePath(String imagePath)
Set the path in HDFS where the HBase image is
|
void |
setInfo(String key,
String value)
Set an information string.
|
void |
setInfoTime(String keyHumanTime,
String keyMachineTime,
long time)
Set the time for an information (human, machine) timestamp pair of fields.
|
void |
setOption(String option,
boolean val)
Set a boolean option
|
void |
setOption(String option,
int val)
Set an integer option -it's converted to a string before saving
|
void |
setOption(String key,
String val)
Set a cluster option: a key val pair in the options {} section
|
void |
setOptionifUnset(String key,
String val)
Set a cluster option if it is unset.
|
void |
setRoleOpt(String role,
String option,
int val)
Set an integer role option, creating the role if necessary
|
void |
setRoleOpt(String role,
String option,
Object val)
Set a role option of any object, using its string value.
|
void |
setRoleOpt(String role,
String option,
String val)
Set a role option, creating the role if necessary
|
void |
setZkHosts(String zkHosts)
Set the hosts for the ZK quorum
|
void |
setZkPath(String zkPath) |
String |
toJsonString()
Convert to a JSON string
|
String |
toString() |
void |
verifyOptionSet(String key)
Verify that an option is set: that is defined AND non-empty
|
protected static final org.slf4j.Logger log
public String version
public String name
public String type
public int state
public static final int STATE_INCOMPLETE
public static final int STATE_SUBMITTED
public static final int STATE_CREATED
public static final int STATE_LIVE
public static final int STATE_STOPPED
public static final int STATE_DESTROYED
public long createTime
info section.public long updateTime
public String originConfigurationPath
public String generatedConfigurationPath
public String dataPath
public Map<String,String> options
public Map<String,String> info
public Map<String,Map<String,Integer>> statistics
public Map<String,String> clientProperties
public ApplicationLivenessInformation liveness
live/liveness/ URLpublic Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic ClusterDescription deepClone()
public void save(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
boolean overwrite)
throws IOException
fs - filesystempath - pathoverwrite - should any existing file be overwrittenIOException - IO exceptionpublic void save(File file) throws IOException
file - fileIOException - IO excpetionpublic static ClusterDescription load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
fs - filesystempath - pathIOException - IO problemsorg.codehaus.jackson.JsonParseExceptionorg.codehaus.jackson.map.JsonMappingExceptionpublic static ClusterDescription copy(ClusterDescription source)
source - sourcepublic String toJsonString() throws IOException, org.codehaus.jackson.JsonGenerationException, org.codehaus.jackson.map.JsonMappingException
IOException - Problems mapping/writing the objectorg.codehaus.jackson.JsonGenerationExceptionorg.codehaus.jackson.map.JsonMappingExceptionpublic static ClusterDescription fromJson(String json) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
json - inputIOException - IOorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic static ClusterDescription fromStream(InputStream is) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
is - input stream of cluster descriptionIOException - IOorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic static ClusterDescription fromFile(File jsonFile) throws IOException, org.codehaus.jackson.JsonParseException, org.codehaus.jackson.map.JsonMappingException
jsonFile - input fileIOException - IO problemsorg.codehaus.jackson.map.JsonMappingException - failure to map from the JSON to this classorg.codehaus.jackson.JsonParseExceptionpublic void setOption(String key, String val)
key - key option nameval - value option valuepublic void setOptionifUnset(String key, String val)
key - key key to query/setval - value valuepublic void setOption(String option, int val)
option - option nameval - integer valuepublic void setOption(String option, boolean val)
option - option nameval - bool valuepublic String getOption(String key, String defVal)
key - option keydefVal - option valpublic String getMandatoryOption(String key) throws BadConfigException
key - mandatory keyBadConfigException - if the option is missingpublic int getOptionInt(String option, int defVal)
Integer.decode(String) so as to take hex
oct and bin values too.option - option namedefVal - default valueNumberFormatException - if the role could not be parsed.public void verifyOptionSet(String key) throws BadConfigException
key - key to verifyBadConfigExceptionpublic boolean getOptionBool(String option, boolean defVal)
Boolean.valueOf(String)
is used for parsing -its policy of what is true vs false applies.option - namedefVal - defaultpublic String getRoleOpt(String role, String option, String defVal)
role - role to get fromoption - option namedefVal - default valuepublic String getMandatoryRoleOpt(String role, String option) throws BadConfigException
role - role to get fromoption - option nameBadConfigException - if the option is not definedpublic int getMandatoryRoleOptInt(String role, String option) throws BadConfigException
role - role to get fromoption - option nameBadConfigException - if the option is not definedpublic Map<String,String> getRole(String role)
role - rolepublic Map<String,String> getOrAddRole(String role)
role - rolepublic Map<String,String> getMandatoryRole(String role) throws BadConfigException
role - role nameBadConfigException - if the role is not therepublic int getRoleOptInt(String role, String option, int defVal)
Integer.decode(String) so as to take hex
oct and bin values too.role - role to get fromoption - option namedefVal - default valueNumberFormatException - if the role could not be parsed.public long getRoleOptLong(String role, String option, long defVal)
Integer.decode(String) so as to take hex
oct and bin values too.role - role to get fromoption - option namedefVal - default valueNumberFormatException - if the role could not be parsed.public void setRoleOpt(String role, String option, String val)
role - role nameoption - option nameval - valuepublic void setRoleOpt(String role, String option, int val)
role - role nameoption - option nameval - integer valuepublic void setRoleOpt(String role, String option, Object val)
role - role nameoption - option nameval - non-null valuepublic int getRoleResourceRequirement(String role, String option, int defVal, int maxVal)
ResourceKeys.YARN_RESOURCE_MAX, which triggers
the return of the maximum value.role - role to get fromoption - option namedefVal - default valuemaxVal - value to return if the max val is requestedNumberFormatException - if the role could not be parsed.public void setInfoTime(String keyHumanTime, String keyMachineTime, long time)
Date class.keyHumanTime - name of human time keykeyMachineTime - name of machine timetime - timestamppublic void setInfo(String key, String value)
key - keyvalue - string valuepublic String getInfo(String key)
key - keypublic boolean getInfoBool(String key)
key - keypublic String getZkHosts() throws BadConfigException
BadConfigExceptionpublic void setZkHosts(String zkHosts)
zkHosts - a comma separated list of hostspublic String getZkPath() throws BadConfigException
BadConfigExceptionpublic void setZkPath(String zkPath)
public String getApplicationHome()
public void setApplicationHome(String applicationHome)
public String getImagePath()
public void setImagePath(String imagePath)
public boolean isImagePathSet()
Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.