Class DeadServer

java.lang.Object
org.apache.hadoop.hbase.master.DeadServer

@Private public class DeadServer extends Object
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 Details

    • LOG

      private static final org.slf4j.Logger LOG
    • deadServers

      private final Map<ServerName,Long> 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.
    • processingServers

      Set of dead servers currently being processed by a SCP. Added to this list at the start of SCP and removed after it is done processing the crash.
  • Constructor Details

  • Method Details

    • isDeadServer

      public boolean isDeadServer(ServerName serverName)
      Parameters:
      serverName - server name.
      Returns:
      true if this server is on the dead servers list false otherwise
    • areDeadServersInProgress

      Checks if there are currently any dead servers being processed by the master. Returns true if at least one region server is currently being processed as dead.
      Returns:
      true if any RS are being processed as dead
    • copyServerNames

    • putIfAbsent

      Adds the server to the dead server list if it's not there already.
    • processing

      public void processing(ServerName sn)
      Add sn< to set of processing deadservers.
      See Also:
    • finish

      public void finish(ServerName sn)
      Complete processing for this dead server.
      Parameters:
      sn - ServerName for the dead server.
      See Also:
    • size

      public int size()
    • isEmpty

      boolean isEmpty()
    • cleanPreviousInstance

      boolean cleanPreviousInstance(ServerName newServerName)
      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 either host:port or host,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

      public String toString()
      Overrides:
      toString in class Object
    • 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

      public Date getTimeOfDeath(ServerName deadServerName)
      Get the time when a server died
      Parameters:
      deadServerName - the dead server name
      Returns:
      the date when the server died
    • removeDeadServer

      public boolean removeDeadServer(ServerName deadServerName)
      Called from rpc by operator cleaning up deadserver list.
      Parameters:
      deadServerName - the dead server name
      Returns:
      true if this server was removed