java.lang.Object
org.apache.hadoop.ozone.container.common.volume.StorageVolume
All Implemented Interfaces:
org.apache.hadoop.hdfs.server.datanode.checker.Checkable<Boolean,org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult>
Direct Known Subclasses:
DbVolume, HddsVolume, MetadataVolume

public abstract class StorageVolume extends Object implements org.apache.hadoop.hdfs.server.datanode.checker.Checkable<Boolean,org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult>
StorageVolume represents a generic Volume in datanode, could be 1. HddsVolume for container storage. 2. MetadataVolume for metadata(ratis) storage. This is a special type of volume, because it is managed by ratis itself, so we don't format or initialize it in Ozone. 3. DbVolume for db instance storage. Each hdds volume has its own VERSION file. The hdds volume will have one clusterUuid directory for each SCM it is a part of. During DN startup, if the VERSION file exists, we verify that the clusterID in the version file matches the clusterID from SCM.
  • Field Details

  • Constructor Details

  • Method Details

    • containerUsedSpace

      protected long containerUsedSpace()
    • getContainerDirsPath

      public File getContainerDirsPath()
    • setGatherContainerUsages

      public void setGatherContainerUsages(Function<HddsVolume,Long> gatherContainerUsages)
    • format

      public void format(String cid) throws IOException
      Throws:
      IOException
    • start

      public void start() throws IOException
      Throws:
      IOException
    • initialize

      protected final void initialize() throws IOException
      Initializes the volume. Creates the Version file if not present, otherwise returns with IOException.
      Throws:
      IOException
    • initializeImpl

      protected void initializeImpl() throws IOException
      Throws:
      IOException
    • createWorkingDir

      public void createWorkingDir(String dirName, MutableVolumeSet dbVolumeSet) throws IOException
      Create the working directory for the volume at //. Creates necessary subdirectories of the working directory as well. This includes the tmp directory at ///tmp. Child classes may override this method to add volume specific subdirectories, but they should call the parent method first to make sure initial directories are constructed.
      Parameters:
      dirName - scmID or clusterID according to SCM HA layout feature upgrade finalization status.
      Throws:
      IOException
    • createTmpDirs

      public void createTmpDirs(String workDirName) throws IOException
      Throws:
      IOException
    • createTmpSubdirIfNeeded

      protected final File createTmpSubdirIfNeeded(String name) throws IOException
      Create a subdirectory within this volume's tmp directory. This subdirectory can be used as a work space for temporary filesystem operations before they are moved to their final destination.
      Throws:
      IOException
    • getVolumeRootDir

      public String getVolumeRootDir()
    • getCurrentUsage

      public org.apache.hadoop.hdds.fs.SpaceUsageSource getCurrentUsage()
      Get current usage of the volume.
    • reportBuilder

      protected StorageLocationReport.Builder reportBuilder()
    • getReport

      public StorageLocationReport getReport()
    • getStorageDir

      public File getStorageDir()
    • getWorkingDirName

      public String getWorkingDirName()
    • getTmpDir

      public File getTmpDir()
    • getDiskCheckDir

      public File getDiskCheckDir()
    • refreshVolumeUsage

      public void refreshVolumeUsage()
    • getVolumeUsage

      public Optional<VolumeUsage> getVolumeUsage()
      See Also:
    • incrementUsedSpace

      public void incrementUsedSpace(long usedSpace)
    • decrementUsedSpace

      public void decrementUsedSpace(long reclaimedSpace)
    • getVolumeSet

      public VolumeSet getVolumeSet()
    • getStorageType

      public org.apache.hadoop.fs.StorageType getStorageType()
    • getStorageID

      public String getStorageID()
    • getClusterID

      public String getClusterID()
    • getDatanodeUuid

      public String getDatanodeUuid()
    • getCTime

      public long getCTime()
    • getLayoutVersion

      public int getLayoutVersion()
    • getStorageState

      public StorageVolume.VolumeState getStorageState()
    • setState

      public void setState(StorageVolume.VolumeState state)
    • isFailed

      public boolean isFailed()
    • getConf

      public org.apache.hadoop.hdds.conf.ConfigurationSource getConf()
    • getDatanodeConfig

      public DatanodeConfiguration getDatanodeConfig()
    • failVolume

      public void failVolume()
    • shutdown

      public void shutdown()
    • check

      public org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult check(@Nullable Boolean unused) throws Exception
      Run a check on the current volume to determine if it is healthy. The check consists of a directory check and an IO check. If the directory check fails, the volume check fails immediately. The IO check is allows to fail up to ioFailureTolerance times out of the last ioTestCount IO checks before this volume check is failed. Each call to this method runs one IO check.
      Specified by:
      check in interface org.apache.hadoop.hdfs.server.datanode.checker.Checkable<Boolean,org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult>
      Parameters:
      unused - context for the check, ignored.
      Returns:
      result of checking the volume.
      Throws:
      InterruptedException - if there was an error during the volume check because the thread was interrupted.
      Exception - if an exception was encountered while running the volume check and the thread was not interrupted.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object