Interface HAContext

All Known Implementing Classes:
NameNode.NameNodeHAContext

@Private public interface HAContext
Context that is to be used by HAState for getting/setting the current state and performing required operations.
  • Method Details

    • setState

      void setState(HAState state)
      Set the state of the context to given state
    • getState

      HAState getState()
      Get the state from the context
    • startActiveServices

      void startActiveServices() throws IOException
      Start the services required in active state
      Throws:
      IOException
    • stopActiveServices

      void stopActiveServices() throws IOException
      Stop the services when exiting active state
      Throws:
      IOException
    • startStandbyServices

      void startStandbyServices() throws IOException
      Start the services required in standby state
      Throws:
      IOException
    • prepareToStopStandbyServices

      void prepareToStopStandbyServices() throws org.apache.hadoop.ha.ServiceFailedException
      Prepare to exit the standby state
      Throws:
      org.apache.hadoop.ha.ServiceFailedException
    • stopStandbyServices

      void stopStandbyServices() throws IOException
      Stop the services when exiting standby state
      Throws:
      IOException
    • writeLock

      void writeLock()
      Take a write-lock on the underlying namesystem so that no concurrent state transitions or edits can be made.
    • writeUnlock

      void writeUnlock()
      Unlock the lock taken by writeLock()
    • checkOperation

      void checkOperation(NameNode.OperationCategory op) throws org.apache.hadoop.ipc.StandbyException
      Verify that the given operation category is allowed in the current state. This is to allow NN implementations (eg BackupNode) to override it with node-specific handling. If the operation which is being checked will be taking the FSNS lock, it's advisable to check the operation category both immediately before and after taking the lock. This is because clients rely on the StandbyException thrown by this method in order to trigger client failover, and if a client first tries to contact the Standby NN, it could block for a long time if the Standby is holding the lock for a while, e.g. when performing a checkpoint. See HDFS-4591 for more details.
      Throws:
      org.apache.hadoop.ipc.StandbyException
    • allowStaleReads

      boolean allowStaleReads()
      Returns:
      true if the node should allow stale reads (ie reads while the namespace is not up to date)