Class BlockPoolSliceStorage
java.lang.Object
org.apache.hadoop.hdfs.server.common.StorageInfo
org.apache.hadoop.hdfs.server.common.Storage
org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceStorage
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.common.Storage
Storage.FormatConfirmable, Storage.StorageDirectory, Storage.StorageDirType, Storage.StorageState -
Field Summary
Fields inherited from class org.apache.hadoop.hdfs.server.common.Storage
LAST_PRE_UPGRADE_LAYOUT_VERSION, LAST_UPGRADABLE_HADOOP_VERSION, LAST_UPGRADABLE_LAYOUT_VERSION, LAYOUT_VERSIONS_203, LOG, STORAGE_1_BBW, STORAGE_DIR_CURRENT, STORAGE_DIR_PREVIOUS, STORAGE_FILE_LOCK, STORAGE_PREVIOUS_CKPT, STORAGE_TMP_FINALIZED, STORAGE_TMP_LAST_CKPT, STORAGE_TMP_PREVIOUS, STORAGE_TMP_REMOVEDFields inherited from class org.apache.hadoop.hdfs.server.common.StorageInfo
clusterID, cTime, layoutVersion, namespaceID, STORAGE_FILE_VERSION, storageType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclearRollingUpgradeMarkers(List<Storage.StorageDirectory> dnStorageDirs) Check whether the rolling upgrade marker file exists for each BP storage root.voidDelete all files and directories in the trash directories.static FileGet a block pool storage root based on data node storage rootgetTrashDirectory(ReplicaInfo info) Get a target subdirectory under trash/ for a given block file that is being deleted.booleanReturn 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.booleanisTrashAllowed(File blockFile) Determine whether we can use trash for the given blockFile.protected voidGet common storage fields.protected voidSet layoutVersion, namespaceID and blockpoolID into block pool storage VERSION filevoidsetRollingUpgradeMarkers(List<Storage.StorageDirectory> dnStorageDirs) Create a rolling upgrade marker file for each BP storage root, if it does not exist already.voidtoString()booleantrash is enabled if at least one storage directory contains trash rootMethods inherited from class org.apache.hadoop.hdfs.server.common.Storage
checkVersionUpgradable, confirmFormat, containsStorageDir, containsStorageDir, containsStorageDir, deleteDir, dirIterable, dirIterator, dirIterator, dirIterator, dirIterator, getBuildVersion, getFiles, getNamespaceInfo, getNumStorageDirs, getRegistrationID, getSingularStorageDir, getStorageDir, getStorageDirs, is203LayoutVersion, listStorageDirectories, nativeCopyFileUnbuffered, rename, unlockAll, writeAll, writeProperties, writeProperties, writePropertiesMethods inherited from class org.apache.hadoop.hdfs.server.common.StorageInfo
checkStorageType, getClusterID, getClusterIdFromColonSeparatedString, getCTime, getLayoutVersion, getNamespaceID, getNsIdFromColonSeparatedString, getProperty, getServiceLayoutFeatureMap, getServiceLayoutVersion, readPreviousVersionProperties, readProperties, readPropertiesFile, setClusterId, setcTime, setLayoutVersion, setNamespaceID, setServiceLayoutVersion, setStorageInfo, toColonSeparatedString, toMapString, versionSupportsFederation
-
Constructor Details
-
BlockPoolSliceStorage
-
-
Method Details
-
addStorageDir
- Overrides:
addStorageDirin classStorage
-
setPropertiesFromFields
protected void setPropertiesFromFields(Properties props, Storage.StorageDirectory sd) throws IOException Set layoutVersion, namespaceID and blockpoolID into block pool storage VERSION file- Overrides:
setPropertiesFromFieldsin classStorage- 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:StorageInfoGet common storage fields. Should be overloaded if additional fields need to be get.- Overrides:
setFieldsFromPropertiesin classStorageInfo- Parameters:
props- properties- Throws:
IOException- on error
-
toString
- Overrides:
toStringin classStorageInfo
-
getBpRoot
Get a block pool storage root based on data node storage root- Parameters:
bpID- block pool IDdnCurDir- data node storage root directory- Returns:
- root directory for block pool storage
-
isPreUpgradableLayout
Description copied from class:StorageReturn 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:
isPreUpgradableLayoutin classStorage- Throws:
IOException
-
isTrashAllowed
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
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
-