Class BlockPoolSliceStorage


@Private public class BlockPoolSliceStorage extends Storage
Manages storage for the set of BlockPoolSlices which share a particular block pool id, on this DataNode. This class supports the following functionality:
  • Formatting a new block pool storage
  • Recovering a storage state to a consistent state (if possible)
  • Taking a snapshot of the block pool during upgrade
  • Rolling back a block pool to a previous snapshot
  • Finalizing block storage by deletion of a snapshot
See Also:
  • Constructor Details

    • BlockPoolSliceStorage

      public BlockPoolSliceStorage(StorageInfo storageInfo, String bpid)
  • Method Details

    • addStorageDir

      public void addStorageDir(Storage.StorageDirectory sd)
      Overrides:
      addStorageDir in class Storage
    • setPropertiesFromFields

      protected void setPropertiesFromFields(Properties props, Storage.StorageDirectory sd) throws IOException
      Set layoutVersion, namespaceID and blockpoolID into block pool storage VERSION file
      Overrides:
      setPropertiesFromFields in class Storage
      Parameters:
      props - the Properties object to write into
      Throws:
      IOException
    • setFieldsFromProperties

      protected void setFieldsFromProperties(Properties props, Storage.StorageDirectory sd) throws IOException
      Description copied from class: StorageInfo
      Get common storage fields. Should be overloaded if additional fields need to be get.
      Overrides:
      setFieldsFromProperties in class StorageInfo
      Parameters:
      props - properties
      Throws:
      IOException - on error
    • toString

      public String toString()
      Overrides:
      toString in class StorageInfo
    • getBpRoot

      public static File getBpRoot(String bpID, File dnCurDir)
      Get a block pool storage root based on data node storage root
      Parameters:
      bpID - block pool ID
      dnCurDir - data node storage root directory
      Returns:
      root directory for block pool storage
    • isPreUpgradableLayout

      public boolean isPreUpgradableLayout(Storage.StorageDirectory sd) throws IOException
      Description copied from class: Storage
      Return true if the layout of the given storage directory is from a version of Hadoop prior to the introduction of the "current" and "previous" directories which allow upgrade and rollback.
      Specified by:
      isPreUpgradableLayout in class Storage
      Throws:
      IOException
    • isTrashAllowed

      @VisibleForTesting public boolean isTrashAllowed(File blockFile)
      Determine whether we can use trash for the given blockFile. Trash is disallowed if a 'previous' directory exists for the storage directory containing the block.
    • getTrashDirectory

      public String getTrashDirectory(ReplicaInfo info)
      Get a target subdirectory under trash/ for a given block file that is being deleted. The subdirectory structure under trash/ mirrors that under current/ to keep implicit memory of where the files are to be restored (if necessary).
      Returns:
      the trash directory for a given block file that is being deleted.
    • clearTrash

      public void clearTrash()
      Delete all files and directories in the trash directories.
    • stopTrashCleaner

      public void stopTrashCleaner()
    • trashEnabled

      @VisibleForTesting public boolean trashEnabled()
      trash is enabled if at least one storage directory contains trash root
    • setRollingUpgradeMarkers

      public void setRollingUpgradeMarkers(List<Storage.StorageDirectory> dnStorageDirs) throws IOException
      Create a rolling upgrade marker file for each BP storage root, if it does not exist already.
      Parameters:
      dnStorageDirs -
      Throws:
      IOException
    • clearRollingUpgradeMarkers

      public void clearRollingUpgradeMarkers(List<Storage.StorageDirectory> dnStorageDirs) throws IOException
      Check whether the rolling upgrade marker file exists for each BP storage root. If it does exist, then the marker file is cleared and more importantly the layout upgrade is finalized.
      Parameters:
      dnStorageDirs -
      Throws:
      IOException