Package org.apache.hadoop.hbase
Class ServerName
java.lang.Object
org.apache.hadoop.hbase.ServerName
- All Implemented Interfaces:
 Serializable,Comparable<ServerName>
- Direct Known Subclasses:
 StartcodeAgnosticServerName
Name of a particular incarnation of an HBase Server. A 
ServerName is used uniquely
 identifying a server instance in a cluster and is made of the combination of hostname, port, and
 startcode. The startcode distinguishes restarted servers on same hostname and port (startcode is
 usually timestamp of server startup). The toString() format of ServerName is safe to use
 in the filesystem and as znode name up in ZooKeeper. Its format is:
 <hostname> 'SERVERNAME_SEPARATOR' <port>
 'SERVERNAME_SEPARATOR' <startcode>. For example, if hostname is
 www.example.org, port is 1234, and the startcode for the regionserver
 is 1212121212, then the toString() would be
 www.example.org,1234,1212121212.
 
 You can obtain a versioned serialized form of this class by calling getVersionedBytes().
 To deserialize, call parseVersionedServerName(byte[]).
 
 Use getAddress() to obtain the Server hostname + port (Endpoint/Socket Address).
 
Immutable.
- See Also:
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Addressprivate byte[]Cached versioned bytes of this ServerName instance.static final List<ServerName>private static final org.apache.hbase.thirdparty.com.google.common.collect.Interner<ServerName>Intern ServerNames.static final intWhat to use if no startcode supplied.private static final longprivate final Stringstatic final Patternstatic final StringThis character is used as separator between server hostname, port and startcode.private final longstatic final StringWhat to use if server name is unknown.private static final shortVersion for this class.(package private) static final byte[] - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServerName(String hostname, int port, long startCode) privateServerName(String hostAndPort, long startCode) privateServerName(Address address, long startCode)  - 
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(ServerName other) booleanDeprecated.Since 2.0.(package private) static StringgetHostNameMinusDomain(String hostname) Deprecated.Since 2.0.intgetPort()(package private) static StringgetServerName(String hostName, int port, long startCode) Deprecated.Since 2.0.static StringgetServerName(String hostAndPort, long startcode) Deprecated.Since 2.0.static StringgetServerNameLessStartCode(String inServerName) Deprecated.Since 2.0.static longgetServerStartcodeFromServerName(String serverName) Deprecated.Since 2.0.longDeprecated.Since 2.5.0, will be removed in 4.0.0.longReturn the start code.byte[]ReturngetServerName()as bytes with a short-sized prefix with theVERSIONof this class.inthashCode()static booleanisFullServerName(String str) Returns true if the String follows the pattern oftoString(), false otherwise.static booleanisSameAddress(ServerName left, ServerName right) Compare two addressesstatic StringparseHostname(String serverName) Deprecated.Since 2.0.static intDeprecated.Since 2.0.static ServerNameparseServerName(String str) Parse a ServerName from a stringstatic longparseStartcode(String serverName) Deprecated.Since 2.0.static ServerNameparseVersionedServerName(byte[] versionedBytes) Use this method instantiating aServerNamefrom bytes gotten from a call togetVersionedBytes().Return a SHORT version oftoString(), one that has the host only, minus the domain, and the port only -- no start code; the String is for us internally mostly tying threads to their server.toString()static ServerNameRetrieve an instance of ServerName.static ServerNameRetrieve an instance of ServerName.static ServerNameRetrieve an instance of ServerName.static ServerNameRetrieve an instance ofServerName. 
- 
Field Details
- 
serialVersionUID
- See Also:
 
 - 
VERSION
Version for this class. Its a short rather than a byte so I can for sure distinguish between this version of this class and the version previous to this which did not have a version.- See Also:
 
 - 
VERSION_BYTES
 - 
NON_STARTCODE
What to use if no startcode supplied.- See Also:
 
 - 
SERVERNAME_SEPARATOR
This character is used as separator between server hostname, port and startcode.- See Also:
 
 - 
SERVERNAME_PATTERN
 - 
UNKNOWN_SERVERNAME
What to use if server name is unknown.- See Also:
 
 - 
serverName
 - 
startCode
 - 
address
 - 
bytes
Cached versioned bytes of this ServerName instance.- See Also:
 
 - 
EMPTY_SERVER_LIST
 - 
INTERN_POOL
private static final org.apache.hbase.thirdparty.com.google.common.collect.Interner<ServerName> INTERN_POOLIntern ServerNames. The Set of ServerNames is mostly-fixed changing slowly as Servers restart. Rather than create a new instance everytime, try and return existing instance if there is one. 
 - 
 - 
Constructor Details
- 
ServerName
 - 
ServerName
 - 
ServerName
 
 - 
 - 
Method Details
- 
getHostNameMinusDomain
Deprecated.Since 2.0. This is for internal use only.- Parameters:
 hostname- the hostname string to get the actual hostname from- Returns:
 - hostname minus the domain, if there is one (will do pass-through on ip addresses)
 
 - 
parseHostname
Deprecated.Since 2.0. UsevalueOf(String) - 
parsePort
Deprecated.Since 2.0. UsevalueOf(String) - 
parseStartcode
Deprecated.Since 2.0. UsevalueOf(String) - 
valueOf
Retrieve an instance of ServerName. Callers should use the equals method to compare returned instances, though we may return a shared immutable object as an internal optimization. - 
valueOf
Retrieve an instance of ServerName. Callers should use the equals method to compare returned instances, though we may return a shared immutable object as an internal optimization. - 
valueOf
Retrieve an instance of ServerName. Callers should use the equals method to compare returned instances, though we may return a shared immutable object as an internal optimization. - 
valueOf
Retrieve an instance ofServerName. Callers should use theequals(Object)method to compare returned instances, though we may return a shared immutable object as an internal optimization.- Parameters:
 address- theAddressto use for getting theServerNamestartCode- the startcode to use for getting theServerName- Returns:
 - the constructed 
ServerName - See Also:
 
 - 
toString
 - 
toShortString
Return a SHORT version oftoString(), one that has the host only, minus the domain, and the port only -- no start code; the String is for us internally mostly tying threads to their server. Not for external use. It is lossy and will not work in in compares, etc. - 
getVersionedBytes
ReturngetServerName()as bytes with a short-sized prefix with theVERSIONof this class. - 
getServerName
 - 
getHostname
 - 
getHostnameLowerCase
 - 
getPort
 - 
getStartcode
Deprecated.Since 2.5.0, will be removed in 4.0.0. UsegetStartCode()instead.Return the start code. - 
getStartCode
Return the start code. - 
getServerName
Deprecated.Since 2.0. UsevalueOf(String, int, long)instead.For internal use only.- Parameters:
 hostName- the name of the host to useport- the port on the host to usestartCode- the startcode to use for formatting- Returns:
 - Server name made of the concatenation of hostname, port and startcode formatted as
         
<hostname> ',' <port> ',' <startcode> 
 - 
getServerName
Deprecated.Since 2.0. UsevalueOf(String, long)instead.- Parameters:
 hostAndPort- String in form of <hostname> ':' <port>startcode- the startcode to use- Returns:
 - Server name made of the concatenation of hostname, port and startcode formatted as
         
<hostname> ',' <port> ',' <startcode> 
 - 
getHostAndPort
Deprecated.Since 2.0. UsegetAddress()instead.- Returns:
 - Hostname and port formatted as described at
         
Addressing.createHostAndPortStr(String, int) 
 - 
getAddress
 - 
getServerStartcodeFromServerName
Deprecated.Since 2.0. Use instance of ServerName to pull out start code.- Parameters:
 serverName- ServerName in form specified bygetServerName()- Returns:
 - The server start code parsed from 
servername 
 - 
getServerNameLessStartCode
Deprecated.Since 2.0. UsegetAddress()Utility method to excise the start code from a server name- Parameters:
 inServerName- full server name- Returns:
 - server name less its start code
 
 - 
compareTo
- Specified by:
 compareToin interfaceComparable<ServerName>
 - 
hashCode
 - 
equals
 - 
isSameAddress
Compare two addresses- Parameters:
 left- the first server address to compareright- the second server address to compare- Returns:
 trueifleftandrighthave the same hostname and port.
 - 
parseVersionedServerName
Use this method instantiating aServerNamefrom bytes gotten from a call togetVersionedBytes(). Will take care of the case where bytes were written by an earlier version of hbase.- Parameters:
 versionedBytes- Pass bytes gotten from a call togetVersionedBytes()- Returns:
 - A ServerName instance.
 - See Also:
 
 - 
parseServerName
Parse a ServerName from a string- Parameters:
 str- Either an instance oftoString()or a "'<hostname>' ':' '<port>'".- Returns:
 - A ServerName instance.
 
 - 
isFullServerName
Returns true if the String follows the pattern oftoString(), false otherwise. 
 -