@InterfaceAudience.Private public class ServerManager extends Object
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.
If a sever is known not to be running any more, it is called dead. The dead server needs to be handled by a ServerShutdownHandler. If the handler is not enabled yet, the server can't be handled right away so it is queued up. After the handler is enabled, the server will be submitted to a handler to handle. However, the handler may be just partially enabled. If so, the server cannot be fully processed, and be queued up for further processing. A server is fully processed only after the handler is fully enabled and has completed the handling.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
ServerManager(MasterServices master)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addServerToDrainList(ServerName sn) |
boolean |
areDeadServersInProgress()
Checks if any dead servers are currently in progress.
|
static void |
closeRegionSilentlyAndWait(ClusterConnection connection,
ServerName server,
HRegionInfo region,
long timeout)
Contacts a region server and waits up to timeout ms
to close the region.
|
int |
countOfRegionServers() |
List<ServerName> |
createDestinationServersList()
Calls
createDestinationServersList(java.util.List<org.apache.hadoop.hbase.ServerName>) without server to exclude. |
List<ServerName> |
createDestinationServersList(List<ServerName> serversToExclude)
Creates a list of possible destinations for a region.
|
void |
expireServer(ServerName serverName) |
double |
getAverageLoad()
Compute the average load across all region servers.
|
DeadServer |
getDeadServers() |
List<ServerName> |
getDrainingServersList() |
org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds |
getLastFlushedSequenceId(byte[] encodedRegionName) |
ServerLoad |
getLoad(ServerName serverName) |
Map<ServerName,ServerLoad> |
getOnlineServers() |
List<ServerName> |
getOnlineServersList() |
List<ServerName> |
getOnlineServersListWithPredicator(List<ServerName> keys,
Predicate<ServerLoad> idleServerPredicator) |
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface |
getRsAdmin(ServerName sn) |
boolean |
isClusterShutdown() |
boolean |
isRegionInServerManagerStates(HRegionInfo hri) |
boolean |
isServerDead(ServerName serverName)
Check if a server is known to be dead.
|
boolean |
isServerOnline(ServerName serverName) |
void |
moveFromOnlineToDeadServers(ServerName sn) |
void |
processDeadServer(ServerName serverName,
boolean shouldSplitWal) |
void |
regionServerReport(ServerName sn,
ServerLoad sl) |
void |
registerListener(ServerListener listener)
Add the listener to the notification list.
|
void |
removeRegion(HRegionInfo regionInfo)
Called by delete table and similar to notify the ServerManager that a region was removed.
|
void |
removeRegions(List<HRegionInfo> regions)
Called by delete table and similar to notify the ServerManager that a region was removed.
|
boolean |
removeServerFromDrainList(ServerName sn) |
void |
sendRegionWarmup(ServerName server,
HRegionInfo region)
Sends a WARMUP RPC to the specified server to warmup the specified region.
|
void |
shutdownCluster() |
void |
stop()
Stop the ServerManager.
|
boolean |
unregisterListener(ServerListener listener)
Remove the listener from the notification list.
|
void |
waitForRegionServers(MonitoredTask status)
Wait for the region servers to report in.
|
public static final String WAIT_ON_REGIONSERVERS_MAXTOSTART
public static final String WAIT_ON_REGIONSERVERS_MINTOSTART
public static final String WAIT_ON_REGIONSERVERS_TIMEOUT
public static final String WAIT_ON_REGIONSERVERS_INTERVAL
public ServerManager(MasterServices master)
master
- ZooKeeperConnectionException
public void registerListener(ServerListener listener)
listener
- The ServerListener to registerpublic boolean unregisterListener(ServerListener listener)
listener
- The ServerListener to unregisterpublic void regionServerReport(ServerName sn, ServerLoad sl) throws YouAreDeadException
YouAreDeadException
public org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds getLastFlushedSequenceId(byte[] encodedRegionName)
public ServerLoad getLoad(ServerName serverName)
serverName
- public double getAverageLoad()
public int countOfRegionServers()
public Map<ServerName,ServerLoad> getOnlineServers()
public DeadServer getDeadServers()
public boolean areDeadServersInProgress()
public void expireServer(ServerName serverName)
public void moveFromOnlineToDeadServers(ServerName sn)
public void processDeadServer(ServerName serverName, boolean shouldSplitWal)
public boolean removeServerFromDrainList(ServerName sn)
public boolean addServerToDrainList(ServerName sn)
public void sendRegionWarmup(ServerName server, HRegionInfo region)
A region server could reject the close request because it either does not have the specified region or the region is being split.
server
- server to warmup a regionregion
- region to warmuppublic static void closeRegionSilentlyAndWait(ClusterConnection connection, ServerName server, HRegionInfo region, long timeout) throws IOException, InterruptedException
IOException
InterruptedException
public org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getRsAdmin(ServerName sn) throws IOException
sn
- sn
IOException
RetriesExhaustedException
- wrapping a ConnectException if failedpublic void waitForRegionServers(MonitoredTask status) throws InterruptedException
InterruptedException
public List<ServerName> getOnlineServersList()
public List<ServerName> getOnlineServersListWithPredicator(List<ServerName> keys, Predicate<ServerLoad> idleServerPredicator)
keys
- The target server nameidleServerPredicator
- Evaluates the server on the given loadpublic List<ServerName> getDrainingServersList()
public boolean isServerOnline(ServerName serverName)
public boolean isServerDead(ServerName serverName)
public void shutdownCluster()
public boolean isClusterShutdown()
public void stop()
public List<ServerName> createDestinationServersList(List<ServerName> serversToExclude)
serversToExclude
- can be null if there is no server to excludepublic List<ServerName> createDestinationServersList()
createDestinationServersList(java.util.List<org.apache.hadoop.hbase.ServerName>)
without server to exclude.public void removeRegion(HRegionInfo regionInfo)
public boolean isRegionInServerManagerStates(HRegionInfo hri)
public void removeRegions(List<HRegionInfo> regions)
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.