Class HddsVolume
java.lang.Object
org.apache.hadoop.ozone.container.common.volume.StorageVolume
org.apache.hadoop.ozone.container.common.volume.HddsVolume
- All Implemented Interfaces:
org.apache.hadoop.hdfs.server.datanode.checker.Checkable<Boolean,org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult>
HddsVolume represents volume in a datanode.
MutableVolumeSet
maintains a list of HddsVolumes, one for each volume in the Datanode.
VolumeUsage in encompassed by this class.
The disk layout per volume is as follows:
../hdds/VERSION
../hdds/<<clusterUuid>>/current/<<containerDir>>/<<containerID >>/metadata
../hdds/<<clusterUuid>>/current/<<containerDir>>/<<containerID >>/<<dataDir>>
Each hdds volume has its own VERSION file. The hdds volume will have one clusterUuid directory for each SCM it is a part of (currently only one SCM is supported).
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 ClassesNested classes/interfaces inherited from class org.apache.hadoop.ozone.container.common.volume.StorageVolume
StorageVolume.VolumeState, StorageVolume.VolumeType -
Field Summary
FieldsFields inherited from class org.apache.hadoop.ozone.container.common.volume.StorageVolume
TMP_DIR_NAME, TMP_DISK_CHECK_DIR_NAME -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResultRun a check on the current volume to determine if it is healthy.org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResultcheckDbHealth(File dbFile) voidvoidDelete all files under volume/hdds/cluster-id/tmp/deleted-containers.voidprotected longvoidcreateDbStore(MutableVolumeSet dbVolumeSet) Pick a DbVolume for HddsVolume and init db instance.voidcreateTmpDirs(String workDirName) voidcreateWorkingDir(String dirName, MutableVolumeSet dbVolumeSet) Create the working directory for the volume at/ / . voidlongreturn the committed space in the volume.longlonggetFreeSpaceToSpare(long volumeCapacity) getType()longincCommittedBytes(long delta) add "delta" bytes to committed space in the volume.booleanbooleanvoidloadDbStore(boolean readOnly) protected StorageLocationReport.BuildervoidsetController(ContainerController controller) voidsetDbParentDir(File dbParentDir) voidsetDbVolume(DbVolume dbVolume) voidsetDeletedContainerDir(File deletedContainerDir) voidsetGatherContainerUsages(Function<HddsVolume, Long> gatherContainerUsages) voidshutdown()Methods inherited from class org.apache.hadoop.ozone.container.common.volume.StorageVolume
createTmpSubdirIfNeeded, decrementUsedSpace, equals, format, getClusterID, getConf, getCTime, getCurrentUsage, getDatanodeConfig, getDatanodeUuid, getDiskCheckDir, getLayoutVersion, getReport, getStorageDir, getStorageID, getStorageState, getStorageType, getTmpDir, getVolumeRootDir, getVolumeSet, getVolumeUsage, getWorkingDirName, hashCode, incrementUsedSpace, initialize, initializeImpl, isFailed, refreshVolumeUsage, setState, start, toString
-
Field Details
-
HDDS_VOLUME_DIR
- See Also:
-
TMP_CONTAINER_DELETE_DIR_NAME
- See Also:
-
-
Method Details
-
createWorkingDir
Description copied from class:StorageVolumeCreate 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. - Overrides:
createWorkingDirin classStorageVolume- Parameters:
dirName- scmID or clusterID according to SCM HA layout feature upgrade finalization status.- Throws:
IOException
-
createTmpDirs
- Overrides:
createTmpDirsin classStorageVolume- Throws:
IOException
-
getHddsRootDir
-
getType
-
getVolumeIOStats
-
getVolumeInfoStats
-
reportBuilder
- Overrides:
reportBuilderin classStorageVolume
-
failVolume
public void failVolume()- Overrides:
failVolumein classStorageVolume
-
shutdown
public void shutdown()- Overrides:
shutdownin classStorageVolume
-
cleanDeletedContainerDir
public void cleanDeletedContainerDir()Delete all files under volume/hdds/cluster-id/tmp/deleted-containers. This is the directory where containers are moved when they are deleted from the system, but before being removed from the filesystem. This makes the deletion atomic. -
check
public org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult check(@Nullable Boolean unused) throws Exception Description copied from class:StorageVolumeRun 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> - Overrides:
checkin classStorageVolume- Parameters:
unused- context for the check, ignored.- Returns:
- result of checking the volume.
- Throws:
Exception- if an exception was encountered while running the volume check and the thread was not interrupted.
-
checkDbHealth
public org.apache.hadoop.hdfs.server.datanode.checker.VolumeCheckResult checkDbHealth(File dbFile) throws InterruptedException - Throws:
InterruptedException
-
checkVolumeUsages
public void checkVolumeUsages() -
incCommittedBytes
public long incCommittedBytes(long delta) add "delta" bytes to committed space in the volume.- Parameters:
delta- bytes to add to committed space counter- Returns:
- bytes of committed space
-
getCommittedBytes
public long getCommittedBytes()return the committed space in the volume.- Returns:
- bytes of committed space
-
getFreeSpaceToSpare
public long getFreeSpaceToSpare(long volumeCapacity) -
setGatherContainerUsages
- Overrides:
setGatherContainerUsagesin classStorageVolume
-
containerUsedSpace
protected long containerUsedSpace()- Overrides:
containerUsedSpacein classStorageVolume
-
getContainerDirsPath
- Overrides:
getContainerDirsPathin classStorageVolume
-
setDbVolume
-
getDbVolume
-
getDbParentDir
-
setDbParentDir
-
getDeletedContainerDir
-
setDeletedContainerDir
-
isDbLoaded
public boolean isDbLoaded() -
isDbLoadFailure
public boolean isDbLoadFailure() -
loadDbStore
- Throws:
IOException
-
setController
-
getContainers
public long getContainers() -
createDbStore
Pick a DbVolume for HddsVolume and init db instance. Use the HddsVolume directly if no DbVolume found.- Parameters:
dbVolumeSet-- Throws:
IOException
-
compactDb
public void compactDb()
-