Class DataStorage
java.lang.Object
org.apache.hadoop.hdfs.server.common.StorageInfo
org.apache.hadoop.hdfs.server.common.Storage
org.apache.hadoop.hdfs.server.datanode.DataStorage
Data storage information file.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classVolumeBuilder holds the metadata (e.g., the storage directories) of the prepared volume returned fromprepareVolume(DataNode, StorageLocation, List).Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.common.Storage
Storage.FormatConfirmable, Storage.StorageDirectory, Storage.StorageDirType, Storage.StorageState -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields 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 TypeMethodDescriptionvoidvoidclearTrash(String bpid) static booleancreateStorageID(Storage.StorageDirectory sd, boolean regenerateStorageIds, org.apache.hadoop.conf.Configuration conf) Create an ID for this storage.voidenableTrash(String bpid) Enable trash for the specified block pool storage.static booleanfullyDelete(File dir) Deprecated.getBPStorage(String bpid) getTrashDirectoryForReplica(String bpid, ReplicaInfo info) If rolling upgrades are in progress then do not delete block files immediately.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.prepareVolume(DataNode datanode, StorageLocation location, List<NamespaceInfo> nsInfos) Prepare a storage directory.voidsetDatanodeUuid(String newDatanodeUuid) protected voidGet common storage fields.protected voidSet common storage fields into the given properties object.voidbooleantrashEnabled(String bpid) Methods inherited from class org.apache.hadoop.hdfs.server.common.Storage
addStorageDir, 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, toString, versionSupportsFederation
-
Field Details
-
BLOCK_SUBDIR_PREFIX
- See Also:
-
STORAGE_DIR_RBW
- See Also:
-
STORAGE_DIR_FINALIZED
- See Also:
-
STORAGE_DIR_LAZY_PERSIST
- See Also:
-
STORAGE_DIR_TMP
- See Also:
-
-
Constructor Details
-
DataStorage
-
-
Method Details
-
getBPStorage
-
getDatanodeUuid
-
setDatanodeUuid
-
createStorageID
public static boolean createStorageID(Storage.StorageDirectory sd, boolean regenerateStorageIds, org.apache.hadoop.conf.Configuration conf) Create an ID for this storage.- Returns:
- true if a new storage ID was generated.
-
enableTrash
Enable trash for the specified block pool storage. Even if trash is enabled by the caller, it is superseded by the 'previous' directory if a layout upgrade is in progress. -
clearTrash
-
trashEnabled
-
setRollingUpgradeMarker
- Throws:
IOException
-
clearRollingUpgradeMarker
- Throws:
IOException
-
getTrashDirectoryForReplica
If rolling upgrades are in progress then do not delete block files immediately. Instead we move the block files to an intermediate 'trash' directory. If there is a subsequent rollback, then the block files will be restored from trash.- Returns:
- trash directory if rolling upgrade is in progress, null otherwise.
-
prepareVolume
public DataStorage.VolumeBuilder prepareVolume(DataNode datanode, StorageLocation location, List<NamespaceInfo> nsInfos) throws IOException Prepare a storage directory. It creates a builder which can be used to add to the volume. If the volume cannot be added, it is OK to discard the builder later.- Parameters:
datanode- DataNode object.location- the StorageLocation for the storage directory.nsInfos- an array of namespace infos.- Returns:
- a VolumeBuilder that holds the metadata of this storage directory and can be added to DataStorage later.
- Throws:
IOException- if encounters I/O errors. Note that if there is IOException, the state of DataStorage is not modified.
-
setPropertiesFromFields
protected void setPropertiesFromFields(Properties props, Storage.StorageDirectory sd) throws IOException Description copied from class:StorageSet common storage fields into the given properties object. Should be overloaded if additional fields need to be set.- 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
-
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
-
fullyDelete
Deprecated.Prefer FileIoProvider#fullydelete.- Parameters:
dir-- Returns:
-