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 Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

  • 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()