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
Modifier and TypeFieldDescriptionprivate Address
private 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 int
What to use if no startcode supplied.private static final long
private final String
static final Pattern
static final String
This character is used as separator between server hostname, port and startcode.private final long
static final String
What to use if server name is unknown.private static final short
Version for this class.(package private) static final byte[]
-
Constructor Summary
ModifierConstructorDescriptionprotected
ServerName
(String hostname, int port, long startCode) private
ServerName
(String hostAndPort, long startCode) private
ServerName
(Address address, long startCode) -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(ServerName other) boolean
Deprecated.Since 2.0.(package private) static String
getHostNameMinusDomain
(String hostname) Deprecated.Since 2.0.int
getPort()
(package private) static String
getServerName
(String hostName, int port, long startCode) Deprecated.Since 2.0.static String
getServerName
(String hostAndPort, long startcode) Deprecated.Since 2.0.static String
getServerNameLessStartCode
(String inServerName) Deprecated.Since 2.0.static long
getServerStartcodeFromServerName
(String serverName) Deprecated.Since 2.0.long
Deprecated.Since 2.5.0, will be removed in 4.0.0.long
Return the start code.byte[]
ReturngetServerName()
as bytes with a short-sized prefix with theVERSION
of this class.int
hashCode()
static boolean
isFullServerName
(String str) Returns true if the String follows the pattern oftoString()
, false otherwise.static boolean
isSameAddress
(ServerName left, ServerName right) Compare two addressesstatic String
parseHostname
(String serverName) Deprecated.Since 2.0.static int
Deprecated.Since 2.0.static ServerName
parseServerName
(String str) Parse a ServerName from a stringstatic long
parseStartcode
(String serverName) Deprecated.Since 2.0.static ServerName
parseVersionedServerName
(byte[] versionedBytes) Use this method instantiating aServerName
from 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 ServerName
Retrieve an instance of ServerName.static ServerName
Retrieve an instance of ServerName.static ServerName
Retrieve an instance of ServerName.static ServerName
Retrieve 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
- theAddress
to use for getting theServerName
startCode
- 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 theVERSION
of 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:
compareTo
in interfaceComparable<ServerName>
-
hashCode
-
equals
-
isSameAddress
Compare two addresses- Parameters:
left
- the first server address to compareright
- the second server address to compare- Returns:
true
ifleft
andright
have the same hostname and port.
-
parseVersionedServerName
Use this method instantiating aServerName
from 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.
-