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 - HServerInfo, load numbers, dying servers, etc.

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.


Constructor Summary
ServerManager(Server master, MasterServices services, MasterMetrics metrics)
          Constructor.
 
Method Summary
 boolean areDeadServersInProgress()
          Checks if any dead servers are currently in progress.
 void expireServer(HServerInfo hsi)
           
 double getAverageLoad()
          Compute the average load across all region servers.
 Set<String> getDeadServers()
           
 HServerInfo getHServerInfo(HServerAddress hsa)
           
 Map<String,HServerInfo> getOnlineServers()
           
 List<HServerInfo> getOnlineServersList()
           
 HServerInfo getServerInfo(String name)
           
 boolean isClusterShutdown()
           
 boolean isServerOnline(String serverName)
           
 boolean sendRegionClose(HServerInfo server, HRegionInfo region)
          Sends an CLOSE RPC to the specified server to close the specified region.
 void sendRegionOpen(HServerInfo server, HRegionInfo region)
          Sends an OPEN RPC to the specified server to open the specified region.
 void sendRegionOpen(HServerInfo server, List<HRegionInfo> regions)
          Sends an OPEN RPC to the specified server to open the specified region.
 void shutdownCluster()
           
 void stop()
          Stop the ServerManager.
 int waitForRegionServers()
          Waits for the regionservers to report in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerManager

public ServerManager(Server master,
                     MasterServices services,
                     MasterMetrics metrics)
Constructor.

Parameters:
master -
services -
metrics -
Method Detail

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

getServerInfo

public HServerInfo getServerInfo(String name)
Parameters:
name - server name
Returns:
HServerInfo for the given server address

getOnlineServers

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

getDeadServers

public Set<String> 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

getHServerInfo

public HServerInfo getHServerInfo(HServerAddress hsa)
Parameters:
hsa -
Returns:
The HServerInfo whose HServerAddress is hsa or null if nothing found.

expireServer

public void expireServer(HServerInfo hsi)

sendRegionOpen

public void sendRegionOpen(HServerInfo server,
                           HRegionInfo region)
                    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
Throws:
IOException

sendRegionOpen

public void sendRegionOpen(HServerInfo 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(HServerInfo server,
                               HRegionInfo region)
                        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
Returns:
true if server acknowledged close, false if not
Throws:
IOException

waitForRegionServers

public int waitForRegionServers()
                         throws InterruptedException
Waits for the regionservers to report in.

Returns:
Count of regions out on cluster
Throws:
InterruptedException

getOnlineServersList

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

isServerOnline

public boolean isServerOnline(String serverName)

shutdownCluster

public void shutdownCluster()

isClusterShutdown

public boolean isClusterShutdown()

stop

public void stop()
Stop the ServerManager. Currently does nothing.



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