Class DirectoryScanner

java.lang.Object
org.apache.hadoop.hdfs.server.datanode.DirectoryScanner
All Implemented Interfaces:
Runnable

@Private public class DirectoryScanner extends Object implements Runnable
Periodically scans the data directories for block and block metadata files. Reconciles the differences with block information maintained in the dataset.
  • Constructor Details

    • DirectoryScanner

      public DirectoryScanner(FsDatasetSpi<?> dataset, org.apache.hadoop.conf.Configuration conf)
      Create a new directory scanner, but don't cycle it running yet.
      Parameters:
      dataset - the dataset to scan
      conf - the Configuration object
  • Method Details

    • setRetainDiffs

      @VisibleForTesting public void setRetainDiffs(boolean b)
      Allow retaining diffs for unit test and analysis. Defaults to false (off).
      Parameters:
      b - whether to retain diffs
    • start

      @VisibleForTesting public void start()
      Start the scanner. The scanner will run every DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY seconds.
    • run

      public void run()
      Main program loop for DirectoryScanner. Runs reconcile() and handles any exceptions.
      Specified by:
      run in interface Runnable
    • reconcile

      @VisibleForTesting public void reconcile() throws IOException
      Reconcile differences between disk and in-memory blocks
      Throws:
      IOException
    • getVolumeReports

      @VisibleForTesting public Collection<DirectoryScanner.ScanInfoVolumeReport> getVolumeReports()
      Get the lists of blocks on the disks in the data set.