@InterfaceAudience.Public @InterfaceStability.Evolving public class ServerName extends Object implements Comparable<ServerName>, Serializable
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[])
Immutable.
Modifier and Type | Field and Description |
---|---|
private byte[] |
bytes
Cached versioned bytes of this ServerName instance.
|
static List<ServerName> |
EMPTY_SERVER_LIST |
private String |
hostnameOnly |
static int |
NON_STARTCODE
What to use if no startcode supplied.
|
private int |
port |
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(String serverName) |
private |
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) |
String |
getHostAndPort() |
String |
getHostname() |
(package private) static String |
getHostNameMinusDomain(String hostname) |
int |
getPort() |
String |
getServerName() |
(package private) static String |
getServerName(String hostName,
int port,
long startcode)
For internal use only.
|
static String |
getServerName(String hostAndPort,
long startcode) |
static String |
getServerNameLessStartCode(String inServerName)
Utility method to excise the start code from a server name
|
static long |
getServerStartcodeFromServerName(String serverName) |
long |
getStartcode() |
byte[] |
getVersionedBytes() |
int |
hashCode() |
static boolean |
isFullServerName(String str) |
static boolean |
isSameHostnameAndPort(ServerName left,
ServerName right) |
static ServerName |
parseFrom(byte[] data)
Get a ServerName from the passed in data bytes.
|
static String |
parseHostname(String serverName) |
static int |
parsePort(String serverName) |
static ServerName |
parseServerName(String str) |
static long |
parseStartcode(String serverName) |
static ServerName |
parseVersionedServerName(byte[] versionedBytes)
Use this method instantiating a
ServerName from bytes
gotten from a call to getVersionedBytes() . |
String |
toShortString() |
String |
toString() |
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 String hostnameOnly
private final int port
private final long startcode
private byte[] bytes
getVersionedBytes()
public static final List<ServerName> EMPTY_SERVER_LIST
private ServerName(String hostname, int port, long startcode)
private ServerName(String serverName)
private ServerName(String hostAndPort, long startCode)
static String getHostNameMinusDomain(String hostname)
hostname
- public static int parsePort(String serverName)
public static long parseStartcode(String serverName)
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 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 ServerName#VERSION of this class.public String getServerName()
public String getHostname()
public int getPort()
public long getStartcode()
static String getServerName(String hostName, int port, long startcode)
hostName
- port
- startcode
- <hostname> ',' <port> ',' <startcode>
public static String getServerName(String hostAndPort, long startcode)
hostAndPort
- String in form of <hostname> ':' <port>startcode
- <hostname> ',' <port> ',' <startcode>
public String getHostAndPort()
Addressing.createHostAndPortStr(String, int)
public static long getServerStartcodeFromServerName(String serverName)
serverName
- ServerName in form specified by getServerName()
servername
public static String getServerNameLessStartCode(String inServerName)
inServerName
- full server namepublic int compareTo(ServerName other)
compareTo
in interface Comparable<ServerName>
public static boolean isSameHostnameAndPort(ServerName left, ServerName right)
left
- right
- other
has 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.public static ServerName parseFrom(byte[] data) throws DeserializationException
data
- Data with a serialize server name in it; can handle the old style
servername where servername was host and port. Works too with data that
begins w/ the pb 'PBUF' magic and that is then followed by a protobuf that
has a serialized ServerName
in it.data
is null else converts passed data
to a ServerName instance.DeserializationException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.