ExternalSPSContext (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.sps, class: ExternalSPSContext

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

# Class ExternalSPSContext

java.lang.Object
org.apache.hadoop.hdfs.server.sps.ExternalSPSContext

All Implemented Interfaces:
  `Context`

@Private public class ExternalSPSContext extends Object implements Context
This class used to connect to Namenode and gets the required information to SPS from Namenode state.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExternalSPSContext(SPSService service, NameNodeConnector nnc)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `closeMetrics()`
  `org.apache.hadoop.hdfs.protocol.HdfsFileStatus`
  `getFileInfo(long path)`
  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.
  `ExternalSPSBeanMetrics`
  `getSpsBeanMetrics()`
  `org.apache.hadoop.hdfs.protocol.BlockStoragePolicy`
  `getStoragePolicy(byte policyId)`
  Gets the storage policy details for the given policy ID.
  `void`
  `initMetrics(StoragePolicySatisfier sps)`
  `boolean`
  `isFileExist(long path)`
  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 inodeId)`
  Remove the hint which was added to track SPS call.
  `void`
  `scanAndCollectFiles(long path)`
  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.

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

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

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### ExternalSPSContext

    public ExternalSPSContext(SPSService service, NameNodeConnector nnc)

- ## Method Details

  - ### isRunning

    public boolean isRunning()
    Description copied from interface: `Context`
    Returns true if the SPS is running, false otherwise.
    Specified by:
      `isRunning` in interface `Context`

  - ### isInSafeMode

    public boolean isInSafeMode()
    Description copied from interface: `Context`
    Returns true if the Namenode in safe mode, false otherwise.
    Specified by:
      `isInSafeMode` in interface `Context`

  - ### getNetworkTopology

    public org.apache.hadoop.net.NetworkTopology getNetworkTopology(StoragePolicySatisfier.DatanodeMap datanodeMap)
    Description copied from interface: `Context`
    Gets the network topology.
    Specified by:
      `getNetworkTopology` in interface `Context`
    Parameters:
      `datanodeMap` - target datanodes
    Returns:
      network topology

  - ### isFileExist

    public boolean isFileExist(long path)
    Description copied from interface: `Context`
    Returns true if the give file exists in the Namespace.
    Specified by:
      `isFileExist` in interface `Context`
    Parameters:
      `path` - - file info
    Returns:
      true if the given file exists, false otherwise.

  - ### getStoragePolicy

    public org.apache.hadoop.hdfs.protocol.BlockStoragePolicy getStoragePolicy(byte policyId)
    Description copied from interface: `Context`
    Gets the storage policy details for the given policy ID.
    Specified by:
      `getStoragePolicy` in interface `Context`
    Parameters:
      `policyId` - - Storage policy ID
    Returns:
      the detailed policy object

  - ### removeSPSHint

    public void removeSPSHint(long inodeId) throws IOException
    Description copied from interface: `Context`
    Remove the hint which was added to track SPS call.
    Specified by:
      `removeSPSHint` in interface `Context`
    Parameters:
      `inodeId` - - user invoked satisfier path
    Throws:
      `IOException`

  - ### getNumLiveDataNodes

    public int getNumLiveDataNodes()
    Description copied from interface: `Context`
    Gets the number of live datanodes in the cluster.
    Specified by:
      `getNumLiveDataNodes` in interface `Context`
    Returns:
      number of live datanodes

  - ### getFileInfo

    public org.apache.hadoop.hdfs.protocol.HdfsFileStatus getFileInfo(long path) throws IOException
    Description copied from interface: `Context`
    Get the file info for a specific file.
    Specified by:
      `getFileInfo` in interface `Context`
    Parameters:
      `path` - file path
    Returns:
      file status metadata information
    Throws:
      `IOException`

  - ### getLiveDatanodeStorageReport

    public org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport[] getLiveDatanodeStorageReport() throws IOException
    Description copied from interface: `Context`
    Returns all the live datanodes and its storage details.
    Specified by:
      `getLiveDatanodeStorageReport` in interface `Context`
    Throws:
      `IOException`

  - ### getNextSPSPath

    public Long getNextSPSPath()
    Specified by:
      `getNextSPSPath` in interface `Context`
    Returns:
      next SPS path info to process.

  - ### scanAndCollectFiles

    public void scanAndCollectFiles(long path) throws IOException, InterruptedException
    Description copied from interface: `Context`
    Do scan and collects the files under that directory and adds to the given BlockStorageMovementNeeded.
    Specified by:
      `scanAndCollectFiles` in interface `Context`
    Parameters:
      `path` - file path
    Throws:
      `IOException`
      `InterruptedException`

  - ### submitMoveTask

    public void submitMoveTask(BlockStorageMovementCommand.BlockMovingInfo blkMovingInfo) throws IOException
    Description copied from interface: `Context`
    Handles the block move tasks. BlockMovingInfo must contain the required info to move the block, that source location, destination location and storage types.
    Specified by:
      `submitMoveTask` in interface `Context`
    Throws:
      `IOException`

  - ### notifyMovementTriedBlocks

    public void notifyMovementTriedBlocks(org.apache.hadoop.hdfs.protocol.Block[] moveAttemptFinishedBlks)
    Description copied from interface: `Context`
    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.
    Specified by:
      `notifyMovementTriedBlocks` in interface `Context`
    Parameters:
      `moveAttemptFinishedBlks` - list of movement attempt finished blocks

  - ### initMetrics

    public void initMetrics(StoragePolicySatisfier sps)

  - ### closeMetrics

    public void closeMetrics()

  - ### getSpsBeanMetrics

    @VisibleForTesting public ExternalSPSBeanMetrics getSpsBeanMetrics()