Package org.apache.hadoop.hbase.master
Class DeadServer
java.lang.Object
org.apache.hadoop.hbase.master.DeadServer
Class to hold dead servers list and utility querying dead server list. Servers are added when
they expire or when we find them in filesystem on startup. When a server crash procedure is
queued, it will populate the processing list and then remove the server from processing list when
done. Servers are removed from dead server list when a new instance is started over the old on
same hostname and port or when new Master comes online tidying up after all initialization.
Processing list and deadserver list are not tied together (you don't have to be in deadservers
list to be processing and vice versa).
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Map<ServerName,
Long> Set of known dead servers.private static final org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) void
cleanAllPreviousInstances
(ServerName newServerName) private boolean
cleanOldServerName
(ServerName newServerName, Iterator<ServerName> deadServerIterator) (package private) boolean
cleanPreviousInstance
(ServerName newServerName) Handles restart of a server.(package private) List<Pair<ServerName,
Long>> copyDeadServersSince
(long ts) Extract all the servers dead since a given time, and sort them.getTimeOfDeath
(ServerName deadServerName) Get the time when a server diedboolean
isDeadServer
(ServerName serverName) (package private) boolean
isEmpty()
(package private) void
Adds the server to the dead server list if it's not there already.boolean
removeDeadServer
(ServerName deadServerName) Called from rpc by operator cleaning up deadserver list.int
size()
toString()
-
Field Details
-
LOG
-
deadServers
Set of known dead servers. On znode expiration, servers are added here. This is needed in case of a network partitioning where the server's lease expires, but the server is still running. After the network is healed, and it's server logs are recovered, it will be told to call server startup because by then, its regions have probably been reassigned.
-
-
Constructor Details
-
DeadServer
public DeadServer()
-
-
Method Details
-
isDeadServer
- Parameters:
serverName
- server name.- Returns:
- true if this server is on the dead servers list false otherwise
-
copyServerNames
-
putIfAbsent
Adds the server to the dead server list if it's not there already. -
size
-
isEmpty
boolean isEmpty() -
cleanPreviousInstance
Handles restart of a server. The new server instance has a different start code. The new start code should be greater than the old one. We don't check that here. Removes the old server from deadserver list.- Parameters:
newServerName
- Servername as eitherhost:port
orhost,port,startcode
.- Returns:
- true if this server was dead before and coming back alive again
-
cleanAllPreviousInstances
-
cleanOldServerName
private boolean cleanOldServerName(ServerName newServerName, Iterator<ServerName> deadServerIterator) - Parameters:
newServerName
- Server to match port and hostname against.deadServerIterator
- Iterator primed so can call 'next' on it.- Returns:
- True if
newServerName
and current primed iterator ServerName have same host and port and we removed old server from iterator and from processing list.
-
toString
-
copyDeadServersSince
Extract all the servers dead since a given time, and sort them.- Parameters:
ts
- the time, 0 for all- Returns:
- a sorted array list, by death time, lowest values first.
-
getTimeOfDeath
Get the time when a server died- Parameters:
deadServerName
- the dead server name- Returns:
- the date when the server died
-
removeDeadServer
Called from rpc by operator cleaning up deadserver list.- Parameters:
deadServerName
- the dead server name- Returns:
- true if this server was removed
-