Class StorageVolume
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStorageVolume.Builder<T extends StorageVolume.Builder<T>>Builder class for StorageVolume.static enumVolumeState represents the different states a StorageVolume can be in.static enumType for StorageVolume. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResultRun a check on the current volume to determine if it is healthy.protected longvoidcreateTmpDirs(String workDirName) protected final FileCreate a subdirectory within this volume's tmp directory.voidcreateWorkingDir(String dirName, MutableVolumeSet dbVolumeSet) Create the working directory for the volume at/ / . voiddecrementUsedSpace(long reclaimedSpace) booleanvoidvoidorg.apache.hadoop.hdds.conf.ConfigurationSourcegetConf()longgetCTime()org.apache.hadoop.hdds.fs.SpaceUsageSourceGet current usage of the volume.intorg.apache.hadoop.fs.StorageTypeinthashCode()voidincrementUsedSpace(long usedSpace) protected final voidInitializes the volume.protected voidbooleanisFailed()voidprotected StorageLocationReport.BuildervoidsetGatherContainerUsages(Function<HddsVolume, Long> gatherContainerUsages) voidvoidshutdown()voidstart()toString()
-
Field Details
-
TMP_DIR_NAME
- See Also:
-
TMP_DISK_CHECK_DIR_NAME
- See Also:
-
-
Constructor Details
-
StorageVolume
- Throws:
IOException
-
-
Method Details
-
containerUsedSpace
protected long containerUsedSpace() -
getContainerDirsPath
-
setGatherContainerUsages
-
format
- Throws:
IOException
-
start
- Throws:
IOException
-
initialize
Initializes the volume. Creates the Version file if not present, otherwise returns with IOException.- Throws:
IOException
-
initializeImpl
- Throws:
IOException
-
createWorkingDir
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
- Throws:
IOException
-
createTmpSubdirIfNeeded
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
-
getCurrentUsage
public org.apache.hadoop.hdds.fs.SpaceUsageSource getCurrentUsage()Get current usage of the volume. -
reportBuilder
-
getReport
-
getStorageDir
-
getWorkingDirName
-
getTmpDir
-
getDiskCheckDir
-
refreshVolumeUsage
public void refreshVolumeUsage() -
getVolumeUsage
- See Also:
-
incrementUsedSpace
public void incrementUsedSpace(long usedSpace) -
decrementUsedSpace
public void decrementUsedSpace(long reclaimedSpace) -
getVolumeSet
-
getStorageType
public org.apache.hadoop.fs.StorageType getStorageType() -
getStorageID
-
getClusterID
-
getDatanodeUuid
-
getCTime
public long getCTime() -
getLayoutVersion
public int getLayoutVersion() -
getStorageState
-
setState
-
isFailed
public boolean isFailed() -
getConf
public org.apache.hadoop.hdds.conf.ConfigurationSource getConf() -
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 toioFailureTolerancetimes out of the lastioTestCountIO checks before this volume check is failed. Each call to this method runs one IO check.- Specified by:
checkin interfaceorg.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() -
equals
-
toString
-