@InterfaceAudience.Public public class ServerName extends Object implements Comparable<ServerName>, Serializable
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.
Modifier and Type | Field and Description |
---|---|
private Address |
address |
private byte[] |
bytes
Cached versioned bytes of this ServerName instance.
|
static List<ServerName> |
EMPTY_SERVER_LIST |
private static org.apache.hbase.thirdparty.com.google.common.collect.Interner<ServerName> |
INTERN_POOL
Intern ServerNames.
|
static int |
NON_STARTCODE
What to use if no startcode supplied.
|
private static long |
serialVersionUID |
private String |
serverName |
static Pattern |
SERVERNAME_PATTERN |
static String |
SERVERNAME_SEPARATOR
This character is used as separator between server hostname, port and startcode.
|
private long |
startCode |
static String |
UNKNOWN_SERVERNAME
What to use if server name is unknown.
|
private static short |
VERSION
Version for this class.
|
(package private) static byte[] |
VERSION_BYTES |
Modifier | Constructor and Description |
---|---|
private |
ServerName(Address address,
long startCode) |
protected |
ServerName(String hostname,
int port,
long startCode) |
private |
ServerName(String hostAndPort,
long startCode) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ServerName other) |
boolean |
equals(Object o) |
Address |
getAddress() |
String |
getHostAndPort()
Deprecated.
Since 2.0. Use
getAddress() instead. |
String |
getHostname() |
String |
getHostnameLowerCase() |
(package private) static String |
getHostNameMinusDomain(String hostname)
Deprecated.
Since 2.0. This is for internal use only.
|
int |
getPort() |
String |
getServerName() |
(package private) static String |
getServerName(String hostName,
int port,
long startCode)
Deprecated.
Since 2.0. Use
valueOf(String, int, long) instead. |
static String |
getServerName(String hostAndPort,
long startcode)
Deprecated.
Since 2.0. Use
valueOf(String, long) instead. |
static String |
getServerNameLessStartCode(String inServerName)
Deprecated.
Since 2.0. Use
getAddress() |
static long |
getServerStartcodeFromServerName(String serverName)
Deprecated.
Since 2.0. Use instance of ServerName to pull out start code.
|
long |
getStartcode()
Deprecated.
Since 2.5.0, will be removed in 4.0.0. Use
getStartCode() instead. |
long |
getStartCode()
Return the start code.
|
byte[] |
getVersionedBytes()
Return
getServerName() as bytes with a short-sized prefix with the VERSION of
this class. |
int |
hashCode() |
static boolean |
isFullServerName(String str)
Returns true if the String follows the pattern of
toString() , false otherwise. |
static boolean |
isSameAddress(ServerName left,
ServerName right)
Compare two addresses
|
static String |
parseHostname(String serverName)
Deprecated.
Since 2.0. Use
valueOf(String) |
static int |
parsePort(String serverName)
Deprecated.
Since 2.0. Use
valueOf(String) |
static ServerName |
parseServerName(String str)
Parse a ServerName from a string
|
static long |
parseStartcode(String serverName)
Deprecated.
Since 2.0. Use
valueOf(String) |
static ServerName |
parseVersionedServerName(byte[] versionedBytes)
Use this method instantiating a
ServerName from bytes gotten from a call to
getVersionedBytes() . |
String |
toShortString()
Return a SHORT version of
toString() , 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. |
String |
toString() |
static ServerName |
valueOf(Address address,
long startCode)
Retrieve an instance of
ServerName . |
static ServerName |
valueOf(String serverName)
Retrieve an instance of ServerName.
|
static ServerName |
valueOf(String hostname,
int port,
long startCode)
Retrieve an instance of ServerName.
|
static ServerName |
valueOf(String hostAndPort,
long startCode)
Retrieve an instance of ServerName.
|
private static final long serialVersionUID
private static final short VERSION
static final byte[] VERSION_BYTES
public static final int NON_STARTCODE
public static final String SERVERNAME_SEPARATOR
public static final Pattern SERVERNAME_PATTERN
public static final String UNKNOWN_SERVERNAME
private final String serverName
private final long startCode
private byte[] bytes
getVersionedBytes()
public static final List<ServerName> EMPTY_SERVER_LIST
private static final org.apache.hbase.thirdparty.com.google.common.collect.Interner<ServerName> INTERN_POOL
protected ServerName(String hostname, int port, long startCode)
private ServerName(Address address, long startCode)
private ServerName(String hostAndPort, long startCode)
@Deprecated static String getHostNameMinusDomain(String hostname)
hostname
- the hostname string to get the actual hostname from@Deprecated public static String parseHostname(String serverName)
valueOf(String)
@Deprecated public static int parsePort(String serverName)
valueOf(String)
@Deprecated public static long parseStartcode(String serverName)
valueOf(String)
public static ServerName valueOf(String hostname, int port, long startCode)
public static ServerName valueOf(String serverName)
public static ServerName valueOf(String hostAndPort, long startCode)
public static ServerName valueOf(Address address, long startCode)
ServerName
. Callers should use the equals(Object)
method to compare returned instances, though we may return a shared immutable object as an
internal optimization.address
- the Address
to use for getting the ServerName
startCode
- the startcode to use for getting the ServerName
ServerName
valueOf(String, int, long)
public String toShortString()
toString()
, 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.public byte[] getVersionedBytes()
getServerName()
as bytes with a short-sized prefix with the VERSION
of
this class.public String getServerName()
public String getHostname()
public String getHostnameLowerCase()
public int getPort()
@Deprecated public long getStartcode()
getStartCode()
instead.public long getStartCode()
@Deprecated static String getServerName(String hostName, int port, long startCode)
valueOf(String, int, long)
instead.hostName
- the name of the host to useport
- the port on the host to usestartCode
- the startcode to use for formatting<hostname> ',' <port> ',' <startcode>
@Deprecated public static String getServerName(String hostAndPort, long startcode)
valueOf(String, long)
instead.hostAndPort
- String in form of <hostname> ':' <port>startcode
- the startcode to use<hostname> ',' <port> ',' <startcode>
@Deprecated public String getHostAndPort()
getAddress()
instead.Addressing.createHostAndPortStr(String, int)
public Address getAddress()
@Deprecated public static long getServerStartcodeFromServerName(String serverName)
serverName
- ServerName in form specified by getServerName()
servername
@Deprecated public static String getServerNameLessStartCode(String inServerName)
getAddress()
inServerName
- full server namepublic int compareTo(ServerName other)
compareTo
in interface Comparable<ServerName>
public static boolean isSameAddress(ServerName left, ServerName right)
left
- the first server address to compareright
- the second server address to comparetrue
if left
and right
have the same hostname and port.public static ServerName parseVersionedServerName(byte[] versionedBytes)
ServerName
from bytes gotten from a call to
getVersionedBytes()
. Will take care of the case where bytes were written by an earlier
version of hbase.versionedBytes
- Pass bytes gotten from a call to getVersionedBytes()
getVersionedBytes()
public static ServerName parseServerName(String str)
str
- Either an instance of toString()
or a "'<hostname>' ':'
'<port>'".public static boolean isFullServerName(String str)
toString()
, false otherwise.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.