org.apache.hadoop.hbase
Class HServerInfo

java.lang.Object
  extended by org.apache.hadoop.hbase.HServerInfo
All Implemented Interfaces:
Comparable<HServerInfo>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<HServerInfo>

public class HServerInfo
extends Object
implements org.apache.hadoop.io.WritableComparable<HServerInfo>

HServerInfo is meta info about an HRegionServer. It is the token by which a master distingushes a particular regionserver from the rest. It holds hostname, ports, regionserver startcode, and load. Each server has a servername where servername is made up of a concatenation of hostname, port, and regionserver startcode. This servername is used in various places identifying this regionserver. Its even used as part of a pathname in the filesystem. As part of the initialization, master will pass the regionserver the address that it knows this regionserver by. In subsequent communications, the regionserver will pass a HServerInfo with the master-supplied address.


Nested Class Summary
static class HServerInfo.LoadComparator
          Orders HServerInfos by load then name.
 
Constructor Summary
HServerInfo()
           
HServerInfo(HServerAddress serverAddress, int infoPort, String hostname)
          Constructor that creates a HServerInfo with a generated startcode and an empty load.
HServerInfo(HServerAddress serverAddress, long startCode, int infoPort, String hostname)
           
HServerInfo(HServerInfo other)
          Copy-constructor
 
Method Summary
 int compareTo(HServerInfo o)
           
 boolean equals(Object obj)
           
 String getHostname()
           
 String getHostnamePort()
           
static String getHostnamePort(String hostname, int port)
           
 int getInfoPort()
           
 HServerLoad getLoad()
           
 HServerAddress getServerAddress()
           
 String getServerName()
          Gets the unique server instance name.
static String getServerName(HServerAddress address, long startCode)
           
static String getServerName(String hostName, int port, long startCode)
           
static String getServerName(String hostAndPort, long startcode)
           
static String getServerNameLessStartCode(String inServerName)
          Utility method to excise the start code from a server name
 long getStartCode()
           
 int hashCode()
           
static boolean isServer(Set<String> servers, String serverName, boolean hostAndPortOnly)
          Utility method that does a find of a servername or a hostandport combination in the passed Set.
 void readFields(DataInput in)
           
 void setLoad(HServerLoad load)
           
 void setServerAddress(HServerAddress serverAddress)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HServerInfo

public HServerInfo()

HServerInfo

public HServerInfo(HServerAddress serverAddress,
                   int infoPort,
                   String hostname)
Constructor that creates a HServerInfo with a generated startcode and an empty load.

Parameters:
serverAddress - An InetSocketAddress encased in a Writable
infoPort - Port the webui runs on.
hostname - Server hostname.

HServerInfo

public HServerInfo(HServerAddress serverAddress,
                   long startCode,
                   int infoPort,
                   String hostname)

HServerInfo

public HServerInfo(HServerInfo other)
Copy-constructor

Parameters:
other -
Method Detail

getLoad

public HServerLoad getLoad()

setLoad

public void setLoad(HServerLoad load)

getServerAddress

public HServerAddress getServerAddress()

setServerAddress

public void setServerAddress(HServerAddress serverAddress)

getStartCode

public long getStartCode()

getInfoPort

public int getInfoPort()

getHostname

public String getHostname()

getHostnamePort

public String getHostnamePort()
Returns:
The hostname and port concatenated with a ':' as separator.

getHostnamePort

public static String getHostnamePort(String hostname,
                                     int port)
Parameters:
hostname -
port -
Returns:
The hostname and port concatenated with a ':' as separator.

getServerName

public String getServerName()
Gets the unique server instance name. Includes the hostname, port, and start code.

Returns:
Server name made of the concatenation of hostname, port and startcode formatted as <hostname> ',' <port> ',' <startcode>

getServerName

public static String getServerName(String hostAndPort,
                                   long startcode)

getServerName

public static String getServerName(HServerAddress address,
                                   long startCode)
Parameters:
address - Server address
startCode - Server startcode
Returns:
Server name made of the concatenation of hostname, port and startcode formatted as <hostname> ',' <port> ',' <startcode>

getServerName

public static String getServerName(String hostName,
                                   int port,
                                   long startCode)

toString

public String toString()
Overrides:
toString in class Object
Returns:
ServerName and load concatenated.
See Also:
getServerName(), getLoad()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(HServerInfo o)
Specified by:
compareTo in interface Comparable<HServerInfo>

isServer

public static boolean isServer(Set<String> servers,
                               String serverName,
                               boolean hostAndPortOnly)
Utility method that does a find of a servername or a hostandport combination in the passed Set.

Parameters:
servers - Set of server names
serverName - Name to look for
hostAndPortOnly - If serverName is a hostname ':' port or hostname , port , startcode.
Returns:
True if serverName found in servers

getServerNameLessStartCode

public static String getServerNameLessStartCode(String inServerName)
Utility method to excise the start code from a server name

Parameters:
inServerName - full server name
Returns:
server name less its start code


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.