NamenodeProtocol (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.protocol, interface: NamenodeProtocol

Package org.apache.hadoop.hdfs.server.protocol

# Interface NamenodeProtocol

All Known Subinterfaces:
  `BalancerProtocols`, `NamenodeProtocols`

All Known Implementing Classes:
  `NamenodeProtocolTranslatorPB`, `NameNodeRpcServer`

@Private public interface NamenodeProtocol
Protocol that a secondary NameNode uses to communicate with the NameNode. Also used by external storage policy satisfier. It's used to get part of the name node state

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ACT_CHECKPOINT`
  `static final int`
  `ACT_SHUTDOWN`
  `static final int`
  `ACT_UNKNOWN`
  `static final int`
  `FATAL`
  `static final int`
  `NOTIFY`
  `static final long`
  `versionID`
  Until version 6L, this class served as both the client interface to the NN AND the RPC protocol used to communicate with the NN.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `endCheckpoint(NamenodeRegistration registration, CheckpointSignature sig)`
  A request to the active name-node to finalize previously started checkpoint.
  `void`
  `errorReport(NamenodeRegistration registration, int errorCode, String msg)`
  Report to the active name-node an error occurred on a subordinate node.
  `ExportedBlockKeys`
  `getBlockKeys()`
  Get the current block keys
  `BlocksWithLocations`
  `getBlocks(org.apache.hadoop.hdfs.protocol.DatanodeInfo datanode, long size, long minBlockSize, long hotBlockTimeInterval, org.apache.hadoop.fs.StorageType storageType)`
  Get a list of blocks belonging to `datanode` whose total size equals `size`.
  `RemoteEditLogManifest`
  `getEditLogManifest(long sinceTxId)`
  Return a structure containing details about all edit logs available to be fetched from the NameNode.
  `long`
  `getMostRecentCheckpointTxId()`
  Get the transaction ID of the most recent checkpoint.
  `long`
  `getMostRecentNameNodeFileTxId(NNStorage.NameNodeFile nnf)`
  Get the transaction ID of the most recent checkpoint for the given NameNodeFile.
  `Long`
  `getNextSPSPath()`
  `long`
  `getTransactionID()`
  `boolean`
  `isRollingUpgrade()`
  return whether the Namenode is rolling upgrade in progress (true) or not (false).
  `boolean`
  `isUpgradeFinalized()`
  `NamenodeRegistration`
  `registerSubordinateNamenode(NamenodeRegistration registration)`
  Register a subordinate name-node like backup node.
  `CheckpointSignature`
  `rollEditLog()`
  Closes the current edit log and opens a new one.
  `NamenodeCommand`
  `startCheckpoint(NamenodeRegistration registration)`
  A request to the active name-node to start a checkpoint.
  `NamespaceInfo`
  `versionRequest()`
  Request name-node version and storage information.

- ## Field Details

  - ### versionID

    static final long versionID
    Until version 6L, this class served as both the client interface to the NN AND the RPC protocol used to communicate with the NN. This class is used by both the DFSClient and the NN server side to insulate from the protocol serialization. If you are adding/changing NN's interface then you need to change both this class and ALSO related protocol buffer wire protocol definition in NamenodeProtocol.proto. For more details on protocol buffer wire protocol, please see .../org/apache/hadoop/hdfs/protocolPB/overview.html 6: Switch to txid-based file naming for image and edits
    See Also:
      - Constant Field Values

  - ### NOTIFY

    static final int NOTIFY
    See Also:
      - Constant Field Values

  - ### FATAL

    static final int FATAL
    See Also:
      - Constant Field Values

  - ### ACT_UNKNOWN

    static final int ACT_UNKNOWN
    See Also:
      - Constant Field Values

  - ### ACT_SHUTDOWN

    static final int ACT_SHUTDOWN
    See Also:
      - Constant Field Values

  - ### ACT_CHECKPOINT

    static final int ACT_CHECKPOINT
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getBlocks

    BlocksWithLocations getBlocks(org.apache.hadoop.hdfs.protocol.DatanodeInfo datanode, long size, long minBlockSize, long hotBlockTimeInterval, org.apache.hadoop.fs.StorageType storageType) throws IOException
    Get a list of blocks belonging to `datanode` whose total size equals `size`.
    Parameters:
      `datanode` - a data node
      `size` - requested size
      `minBlockSize` - each block should be of this minimum Block Size
      `hotBlockTimeInterval` - prefer to get blocks which are belong to the cold files accessed before the time interval
      `storageType` - the given storage type `StorageType`
    Returns:
      BlocksWithLocations a list of blocks & their locations
    Throws:
      `IOException` - if size is less than or equal to 0 or datanode does not exist
    See Also:
      - `Balancer`

  - ### getBlockKeys

    ExportedBlockKeys getBlockKeys() throws IOException
    Get the current block keys
    Returns:
      ExportedBlockKeys containing current block keys
    Throws:
      `IOException`

  - ### getTransactionID

    long getTransactionID() throws IOException
    Returns:
      The most recent transaction ID that has been synced to persistent storage, or applied from persistent storage in the case of a non-active node.
    Throws:
      `IOException`

  - ### getMostRecentCheckpointTxId

    long getMostRecentCheckpointTxId() throws IOException
    Get the transaction ID of the most recent checkpoint.
    Throws:
      `IOException`

  - ### getMostRecentNameNodeFileTxId

    long getMostRecentNameNodeFileTxId(NNStorage.NameNodeFile nnf) throws IOException
    Get the transaction ID of the most recent checkpoint for the given NameNodeFile.
    Throws:
      `IOException`

  - ### rollEditLog

    CheckpointSignature rollEditLog() throws IOException
    Closes the current edit log and opens a new one. The call fails if the file system is in SafeMode.
    Returns:
      a unique token to identify this transaction.
    Throws:
      `IOException`

  - ### versionRequest

    NamespaceInfo versionRequest() throws IOException
    Request name-node version and storage information.
    Returns:
      `NamespaceInfo` identifying versions and storage information of the name-node
    Throws:
      `IOException`

  - ### errorReport

    void errorReport(NamenodeRegistration registration, int errorCode, String msg) throws IOException
    Report to the active name-node an error occurred on a subordinate node. Depending on the error code the active node may decide to unregister the reporting node.
    Parameters:
      `registration` - requesting node.
      `errorCode` - indicates the error
      `msg` - free text description of the error
    Throws:
      `IOException`

  - ### registerSubordinateNamenode

    NamenodeRegistration registerSubordinateNamenode(NamenodeRegistration registration) throws IOException
    Register a subordinate name-node like backup node.
    Returns:
      `NamenodeRegistration` of the node, which this node has just registered with.
    Throws:
      `IOException`

  - ### startCheckpoint

    NamenodeCommand startCheckpoint(NamenodeRegistration registration) throws IOException
    A request to the active name-node to start a checkpoint. The name-node should decide whether to admit it or reject. The name-node also decides what should be done with the backup node image before and after the checkpoint.
    Parameters:
      `registration` - the requesting node
    Returns:
      `CheckpointCommand` if checkpoint is allowed.
    Throws:
      `IOException`
    See Also:
      - `CheckpointCommand`
      - `NamenodeCommand`
      - `ACT_SHUTDOWN`

  - ### endCheckpoint

    void endCheckpoint(NamenodeRegistration registration, CheckpointSignature sig) throws IOException
    A request to the active name-node to finalize previously started checkpoint.
    Parameters:
      `registration` - the requesting node
      `sig` - `CheckpointSignature` which identifies the checkpoint.
    Throws:
      `IOException`

  - ### getEditLogManifest

    RemoteEditLogManifest getEditLogManifest(long sinceTxId) throws IOException
    Return a structure containing details about all edit logs available to be fetched from the NameNode.
    Parameters:
      `sinceTxId` - return only logs that contain transactions >= sinceTxId
    Throws:
      `IOException`

  - ### isUpgradeFinalized

    boolean isUpgradeFinalized() throws IOException
    Returns:
      Whether the NameNode is in upgrade state (false) or not (true)
    Throws:
      `IOException`

  - ### isRollingUpgrade

    boolean isRollingUpgrade() throws IOException
    return whether the Namenode is rolling upgrade in progress (true) or not (false).
    Returns:
    Throws:
      `IOException`

  - ### getNextSPSPath

    Long getNextSPSPath() throws IOException
    Returns:
      Gets the next available sps path, otherwise null. This API used by External SPS.
    Throws:
      `IOException`