Context (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.namenode.sps, interface: Context

Package org.apache.hadoop.hdfs.server.namenode.sps

# Interface Context

All Known Implementing Classes:
  `ExternalSPSContext`

@Private @Evolving public interface Context
An interface for the communication between SPS and Namenode module.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.apache.hadoop.hdfs.protocol.HdfsFileStatus`
  `getFileInfo(long file)`
  Get the file info for a specific file.
  `org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport[]`
  `getLiveDatanodeStorageReport()`
  Returns all the live datanodes and its storage details.
  `org.apache.hadoop.net.NetworkTopology`
  `getNetworkTopology(StoragePolicySatisfier.DatanodeMap datanodeMap)`
  Gets the network topology.
  `Long`
  `getNextSPSPath()`
  `int`
  `getNumLiveDataNodes()`
  Gets the number of live datanodes in the cluster.
  `org.apache.hadoop.hdfs.protocol.BlockStoragePolicy`
  `getStoragePolicy(byte policyId)`
  Gets the storage policy details for the given policy ID.
  `boolean`
  `isFileExist(long filePath)`
  Returns true if the give file exists in the Namespace.
  `boolean`
  `isInSafeMode()`
  Returns true if the Namenode in safe mode, false otherwise.
  `boolean`
  `isRunning()`
  Returns true if the SPS is running, false otherwise.
  `void`
  `notifyMovementTriedBlocks(org.apache.hadoop.hdfs.protocol.Block[] moveAttemptFinishedBlks)`
  This can be used to notify to the SPS about block movement attempt finished.
  `void`
  `removeSPSHint(long spsPath)`
  Remove the hint which was added to track SPS call.
  `void`
  `scanAndCollectFiles(long filePath)`
  Do scan and collects the files under that directory and adds to the given BlockStorageMovementNeeded.
  `void`
  `submitMoveTask(BlockStorageMovementCommand.BlockMovingInfo blkMovingInfo)`
  Handles the block move tasks.

- ## Method Details

  - ### isRunning

    boolean isRunning()
    Returns true if the SPS is running, false otherwise.

  - ### isInSafeMode

    boolean isInSafeMode()
    Returns true if the Namenode in safe mode, false otherwise.

  - ### getNetworkTopology

    org.apache.hadoop.net.NetworkTopology getNetworkTopology(StoragePolicySatisfier.DatanodeMap datanodeMap)
    Gets the network topology.
    Parameters:
      `datanodeMap` - target datanodes
    Returns:
      network topology

  - ### isFileExist

    boolean isFileExist(long filePath)
    Returns true if the give file exists in the Namespace.
    Parameters:
      `filePath` - - file info
    Returns:
      true if the given file exists, false otherwise.

  - ### getStoragePolicy

    org.apache.hadoop.hdfs.protocol.BlockStoragePolicy getStoragePolicy(byte policyId)
    Gets the storage policy details for the given policy ID.
    Parameters:
      `policyId` - - Storage policy ID
    Returns:
      the detailed policy object

  - ### removeSPSHint

    void removeSPSHint(long spsPath) throws IOException
    Remove the hint which was added to track SPS call.
    Parameters:
      `spsPath` - - user invoked satisfier path
    Throws:
      `IOException`

  - ### getNumLiveDataNodes

    int getNumLiveDataNodes()
    Gets the number of live datanodes in the cluster.
    Returns:
      number of live datanodes

  - ### getFileInfo

    org.apache.hadoop.hdfs.protocol.HdfsFileStatus getFileInfo(long file) throws IOException
    Get the file info for a specific file.
    Parameters:
      `file` - file path
    Returns:
      file status metadata information
    Throws:
      `IOException`

  - ### getLiveDatanodeStorageReport

    org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport[] getLiveDatanodeStorageReport() throws IOException
    Returns all the live datanodes and its storage details.
    Throws:
      `IOException`

  - ### getNextSPSPath

    Long getNextSPSPath()
    Returns:
      next SPS path info to process.

  - ### scanAndCollectFiles

    void scanAndCollectFiles(long filePath) throws IOException, InterruptedException
    Do scan and collects the files under that directory and adds to the given BlockStorageMovementNeeded.
    Parameters:
      `filePath` - file path
    Throws:
      `IOException`
      `InterruptedException`

  - ### submitMoveTask

    void submitMoveTask(BlockStorageMovementCommand.BlockMovingInfo blkMovingInfo) throws IOException
    Handles the block move tasks. BlockMovingInfo must contain the required info to move the block, that source location, destination location and storage types.
    Throws:
      `IOException`

  - ### notifyMovementTriedBlocks

    void notifyMovementTriedBlocks(org.apache.hadoop.hdfs.protocol.Block[] moveAttemptFinishedBlks)
    This can be used to notify to the SPS about block movement attempt finished. Then SPS will re-check whether it needs retry or not.
    Parameters:
      `moveAttemptFinishedBlks` - list of movement attempt finished blocks