public class ClustersNames extends Object
The class will automatically load a resource named URL_TO_NAME_MAP_RESOURCE_NAME to
get a default mapping. It expects this resource to be in the Java Properties file format. The
name of the property is the cluster URL and the value is the human-readable name.
IMPORTANT: Don't forget to escape colons ":" in the file as those may be interpreted as name/value separators.
| Modifier and Type | Field and Description |
|---|---|
static String |
URL_TO_NAME_MAP_RESOURCE_NAME |
| Modifier | Constructor and Description |
|---|---|
protected |
ClustersNames() |
| Modifier and Type | Method and Description |
|---|---|
void |
addClusterMapping(String clusterUrl,
String clusterName) |
void |
addClusterMapping(URL clusterUrl,
String clusterName) |
String |
getClusterName()
Returns the cluster name on which the application is running.
|
String |
getClusterName(org.apache.hadoop.conf.Configuration conf)
Returns the cluster name on which the application is running.
|
String |
getClusterName(String clusterUrl)
Returns human-readable name of the cluster.
|
static ClustersNames |
getInstance() |
public static final String URL_TO_NAME_MAP_RESOURCE_NAME
public String getClusterName(String clusterUrl)
public String getClusterName()
Configuration to get the
url of the resourceManager or jobtracker. The URL is then translated into a human readable cluster name using
getClusterName(String)getClusterName(Configuration)public String getClusterName(org.apache.hadoop.conf.Configuration conf)
getClusterName(String)
MapReduce mode Uses the value for "yarn.resourcemanager.address" from Configuration excluding the
port number.
Standalone mode (outside of hadoop) Uses the Hostname of InetAddress.getLocalHost()
Use getClusterName(String) if you already have the cluster URL
conf - Hadoop configuration to use to get resourceManager or jobTracker URLsgetClusterName()public static ClustersNames getInstance()