org.apache.hadoop.hdfs.server.namenode

## Class NameNode.NameNodeHAContext

- java.lang.Object
- - org.apache.hadoop.hdfs.server.namenode.NameNode.NameNodeHAContext

- All Implemented Interfaces:
    org.apache.hadoop.hdfs.server.namenode.ha.HAContext
  Enclosing class:
    org.apache.hadoop.hdfs.server.namenode.NameNode

      protected class NameNode.NameNodeHAContext
      extends Object
      implements org.apache.hadoop.hdfs.server.namenode.ha.HAContext

  Class used to expose `NameNode` as context to `HAState`

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `NameNodeHAContext()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `allowStaleReads()`
    `void` | `checkOperation(NameNode.OperationCategory op)` Check if an operation of given category is allowed
    `org.apache.hadoop.hdfs.server.namenode.ha.HAState` | `getState()` Get the state from the context
    `void` | `prepareToStopStandbyServices()` Prepare to exit the standby state
    `void` | `setState(org.apache.hadoop.hdfs.server.namenode.ha.HAState s)` Set the state of the context to given `state`
    `void` | `startActiveServices()` Start the services required in active state
    `void` | `startStandbyServices()` Start the services required in standby state
    `void` | `stopActiveServices()` Stop the services when exiting active state
    `void` | `stopStandbyServices()` Stop the services when exiting standby state
    `void` | `writeLock()` Take a write-lock on the underlying namesystem so that no concurrent state transitions or edits can be made.
    `void` | `writeUnlock()` Unlock the lock taken by `HAContext.writeLock()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NameNodeHAContext

          protected NameNodeHAContext()

  - ### Method Detail

    - #### setState

          public void setState(org.apache.hadoop.hdfs.server.namenode.ha.HAState s)

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Set the state of the context to given `state`
      Specified by:
        `setState` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`

    - #### getState

          public org.apache.hadoop.hdfs.server.namenode.ha.HAState getState()

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Get the state from the context
      Specified by:
        `getState` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`

    - #### startActiveServices

          public void startActiveServices()
                                   throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Start the services required in active state
      Specified by:
        `startActiveServices` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `IOException`

    - #### stopActiveServices

          public void stopActiveServices()
                                  throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Stop the services when exiting active state
      Specified by:
        `stopActiveServices` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `IOException`

    - #### startStandbyServices

          public void startStandbyServices()
                                    throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Start the services required in standby state
      Specified by:
        `startStandbyServices` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `IOException`

    - #### prepareToStopStandbyServices

          public void prepareToStopStandbyServices()
                                            throws org.apache.hadoop.ha.ServiceFailedException

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Prepare to exit the standby state
      Specified by:
        `prepareToStopStandbyServices` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `org.apache.hadoop.ha.ServiceFailedException`

    - #### stopStandbyServices

          public void stopStandbyServices()
                                   throws IOException

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Stop the services when exiting standby state
      Specified by:
        `stopStandbyServices` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `IOException`

    - #### writeLock

          public void writeLock()

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Take a write-lock on the underlying namesystem so that no concurrent state transitions or edits can be made.
      Specified by:
        `writeLock` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`

    - #### writeUnlock

          public void writeUnlock()

      Description copied from interface: `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Unlock the lock taken by `HAContext.writeLock()`
      Specified by:
        `writeUnlock` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`

    - #### checkOperation

          public void checkOperation(NameNode.OperationCategory op)
                              throws org.apache.hadoop.ipc.StandbyException

      Check if an operation of given category is allowed
      Specified by:
        `checkOperation` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Throws:
        `org.apache.hadoop.ipc.StandbyException`

    - #### allowStaleReads

          public boolean allowStaleReads()

      Specified by:
        `allowStaleReads` in interface `org.apache.hadoop.hdfs.server.namenode.ha.HAContext`
      Returns:
        true if the node should allow stale reads (ie reads while the namespace is not up to date)

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.