org.apache.hadoop.hbase.master
Class ServerManager

java.lang.Object
  extended by org.apache.hadoop.hbase.master.ServerManager

public class ServerManager
extends Object

The ServerManager class manages info about region servers.

Maintains lists of online and dead servers. Processes the startups, shutdowns, and deaths of region servers.

Servers are distinguished in two different ways. A given server has a location, specified by hostname and port, and of which there can only be one online at any given time. A server instance is specified by the location (hostname and port) as well as the startcode (timestamp from when the server was started). This is used to differentiate a restarted instance of a given server from the original instance.


Field Summary
static String WAIT_ON_REGIONSERVERS_INTERVAL
           
static String WAIT_ON_REGIONSERVERS_MAXTOSTART
           
static String WAIT_ON_REGIONSERVERS_MINTOSTART
           
static String WAIT_ON_REGIONSERVERS_TIMEOUT
           
 
Constructor Summary
ServerManager(Server master, MasterServices services)
          Constructor.
 
Method Summary
 boolean addServerToDrainList(ServerName sn)
           
 boolean areDeadServersInProgress()
          Checks if any dead servers are currently in progress.
 void expireServer(ServerName serverName)
           
 double getAverageLoad()
          Compute the average load across all region servers.
 Set<ServerName> getDeadServers()
           
 List<ServerName> getDrainingServersList()
           
 HServerLoad getLoad(HServerAddress address)
          Deprecated. Use getLoad(HServerAddress)
 HServerLoad getLoad(ServerName serverName)
           
 Map<ServerName,HServerLoad> getOnlineServers()
           
 List<ServerName> getOnlineServersList()
           
 boolean isClusterShutdown()
           
 boolean isServerOnline(ServerName serverName)
           
 boolean removeServerFromDrainList(ServerName sn)
           
 boolean sendRegionClose(ServerName server, HRegionInfo region, int versionOfClosingNode)
          Sends an CLOSE RPC to the specified server to close the specified region.
 RegionOpeningState sendRegionOpen(ServerName server, HRegionInfo region, int versionOfOfflineNode)
          Sends an OPEN RPC to the specified server to open the specified region.
 void sendRegionOpen(ServerName server, List<HRegionInfo> regions)
          Sends an OPEN RPC to the specified server to open the specified region.
 void shutdownCluster()
           
 void stop()
          Stop the ServerManager.
 void waitForRegionServers(MonitoredTask status)
          Wait for the region servers to report in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAIT_ON_REGIONSERVERS_MAXTOSTART

public static final String WAIT_ON_REGIONSERVERS_MAXTOSTART
See Also:
Constant Field Values

WAIT_ON_REGIONSERVERS_MINTOSTART

public static final String WAIT_ON_REGIONSERVERS_MINTOSTART
See Also:
Constant Field Values

WAIT_ON_REGIONSERVERS_TIMEOUT

public static final String WAIT_ON_REGIONSERVERS_TIMEOUT
See Also:
Constant Field Values

WAIT_ON_REGIONSERVERS_INTERVAL

public static final String WAIT_ON_REGIONSERVERS_INTERVAL
See Also:
Constant Field Values
Constructor Detail

ServerManager

public ServerManager(Server master,
                     MasterServices services)
              throws ZooKeeperConnectionException
Constructor.

Parameters:
master -
services -
Throws:
ZooKeeperConnectionException
Method Detail

getLoad

public HServerLoad getLoad(ServerName serverName)
Parameters:
serverName -
Returns:
HServerLoad if serverName is known else null

getLoad

public HServerLoad getLoad(HServerAddress address)
Deprecated. Use getLoad(HServerAddress)

Parameters:
address -
Returns:
HServerLoad if serverName is known else null

getAverageLoad

public double getAverageLoad()
Compute the average load across all region servers. Currently, this uses a very naive computation - just uses the number of regions being served, ignoring stats about number of requests.

Returns:
the average load

getOnlineServers

public Map<ServerName,HServerLoad> getOnlineServers()
Returns:
Read-only map of servers to serverinfo

getDeadServers

public Set<ServerName> getDeadServers()

areDeadServersInProgress

public boolean areDeadServersInProgress()
Checks if any dead servers are currently in progress.

Returns:
true if any RS are being processed as dead, false if not

expireServer

public void expireServer(ServerName serverName)

removeServerFromDrainList

public boolean removeServerFromDrainList(ServerName sn)

addServerToDrainList

public boolean addServerToDrainList(ServerName sn)

sendRegionOpen

public RegionOpeningState sendRegionOpen(ServerName server,
                                         HRegionInfo region,
                                         int versionOfOfflineNode)
                                  throws IOException
Sends an OPEN RPC to the specified server to open the specified region.

Open should not fail but can if server just crashed.

Parameters:
server - server to open a region
region - region to open
versionOfOfflineNode - that needs to be present in the offline node when RS tries to change the state from OFFLINE to other states.
Throws:
IOException

sendRegionOpen

public void sendRegionOpen(ServerName server,
                           List<HRegionInfo> regions)
                    throws IOException
Sends an OPEN RPC to the specified server to open the specified region.

Open should not fail but can if server just crashed.

Parameters:
server - server to open a region
regions - regions to open
Throws:
IOException

sendRegionClose

public boolean sendRegionClose(ServerName server,
                               HRegionInfo region,
                               int versionOfClosingNode)
                        throws IOException
Sends an CLOSE RPC to the specified server to close the specified region.

A region server could reject the close request because it either does not have the specified region or the region is being split.

Parameters:
server - server to open a region
region - region to open
versionOfClosingNode - the version of znode to compare when RS transitions the znode from CLOSING state.
Returns:
true if server acknowledged close, false if not
Throws:
IOException

waitForRegionServers

public void waitForRegionServers(MonitoredTask status)
                          throws InterruptedException
Wait for the region servers to report in. We will wait until one of this condition is met: - the master is stopped - the 'hbase.master.wait.on.regionservers.maxtostart' number of region servers is reached - the 'hbase.master.wait.on.regionservers.mintostart' is reached AND there have been no new region server in for 'hbase.master.wait.on.regionservers.interval' time AND the 'hbase.master.wait.on.regionservers.timeout' is reached

Throws:
InterruptedException

getOnlineServersList

public List<ServerName> getOnlineServersList()
Returns:
A copy of the internal list of online servers.

getDrainingServersList

public List<ServerName> getDrainingServersList()
Returns:
A copy of the internal list of draining servers.

isServerOnline

public boolean isServerOnline(ServerName serverName)

shutdownCluster

public void shutdownCluster()

isClusterShutdown

public boolean isClusterShutdown()

stop

public void stop()
Stop the ServerManager. Currently closes the connection to the master.



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