Storage.FormatConfirmable@Private public static class Storage.StorageDirectory extends java.lang.Object implements Storage.FormatConfirmable
| Constructor | Description |
|---|---|
StorageDirectory(java.io.File dir) |
|
StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType) |
|
StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType,
boolean isShared) |
Constructor
|
StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType,
boolean isShared,
org.apache.hadoop.fs.permission.FsPermission permission) |
|
StorageDirectory(java.lang.String bpid,
Storage.StorageDirType dirType,
boolean isShared,
StorageLocation location) |
Constructor
|
StorageDirectory(Storage.StorageDirType dirType,
boolean isShared,
StorageLocation location) |
Constructor
|
StorageDirectory(StorageLocation location) |
| Modifier and Type | Method | Description |
|---|---|---|
Storage.StorageState |
analyzeStorage(HdfsServerConstants.StartupOption startOpt,
Storage storage) |
Check consistency of the storage directory.
|
Storage.StorageState |
analyzeStorage(HdfsServerConstants.StartupOption startOpt,
Storage storage,
boolean checkCurrentIsEmpty) |
Check consistency of the storage directory.
|
void |
clearDirectory() |
Clear and re-create storage directory.
|
void |
doRecover(Storage.StorageState curState) |
Complete or recover storage state from previously failed transition.
|
java.io.File |
getCurrentDir() |
Directory
current contains latest files defining
the file system meta-data. |
long |
getDirecorySize() |
Get storage directory size.
|
java.io.File |
getFinalizedTmp() |
finalized.tmp is a transient directory, which holds
the previous file system state while it is being removed
in response to the finalize request. |
java.io.File |
getLastCheckpointTmp() |
lastcheckpoint.tmp is a transient directory, which holds
current file system state while the new state is saved into the new
current during regular namespace updates. |
java.io.File |
getPreviousCheckpoint() |
previous.checkpoint is a directory, which holds the previous
(before the last save) state of the storage directory. |
java.io.File |
getPreviousDir() |
Directory
previous contains the previous file system state,
which the system can be rolled back to. |
java.io.File |
getPreviousTmp() |
previous.tmp is a transient directory, which holds
current file system state while the new state is saved into the new
current during upgrade. |
java.io.File |
getPreviousVersionFile() |
File
VERSION from the previous directory. |
java.io.File |
getRemovedTmp() |
removed.tmp is a transient directory, which holds
current file system state while the previous state is moved into
current during rollback. |
java.io.File |
getRoot() |
Get root directory of this storage
|
Storage.StorageDirType |
getStorageDirType() |
Get storage directory type
|
StorageLocation |
getStorageLocation() |
|
java.lang.String |
getStorageUuid() |
|
java.io.File |
getVersionFile() |
File
VERSION contains the following fields:
node type
layout version
namespaceID
fs state creation time
other fields specific for this node type
The version file is always written last during storage directory updates. |
boolean |
hasSomeData() |
|
boolean |
isLockSupported() |
Check whether underlying file system supports file locking.
|
boolean |
isShared() |
|
void |
lock() |
Lock storage to provide exclusive access.
|
void |
read(java.io.File from,
Storage storage) |
|
void |
setStorageUuid(java.lang.String storageUuid) |
|
java.lang.String |
toString() |
|
void |
unlock() |
Unlock storage.
|
public StorageDirectory(java.io.File dir)
public StorageDirectory(StorageLocation location)
public StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType)
public StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType,
boolean isShared)
dir - directory corresponding to the storagedirType - storage directory typeisShared - whether or not this dir is shared between two NNs. true
disables locking on the storage directory, false enables lockingpublic StorageDirectory(java.io.File dir,
Storage.StorageDirType dirType,
boolean isShared,
org.apache.hadoop.fs.permission.FsPermission permission)
public StorageDirectory(Storage.StorageDirType dirType, boolean isShared, StorageLocation location)
dirType - storage directory typeisShared - whether or not this dir is shared between two NNs. true
disables locking on the storage directory, false enables lockinglocation - the StorageLocation for this directorypublic StorageDirectory(java.lang.String bpid,
Storage.StorageDirType dirType,
boolean isShared,
StorageLocation location)
bpid - the block pool iddirType - storage directory typeisShared - whether or not this dir is shared between two NNs. true
disables locking on the storage directory, false enables lockinglocation - the StorageLocation for this directorypublic void setStorageUuid(java.lang.String storageUuid)
public java.lang.String getStorageUuid()
public java.io.File getRoot()
public Storage.StorageDirType getStorageDirType()
public long getDirecorySize()
public void read(java.io.File from,
Storage storage)
throws java.io.IOException
java.io.IOExceptionpublic void clearDirectory()
throws java.io.IOException
Removes contents of the current directory and creates an empty directory. This does not fully format storage directory. It cannot write the version file since it should be written last after all other storage type dependent files are written. Derived storage is responsible for setting specific storage values and writing the version file to disk.
java.io.IOExceptionpublic java.io.File getCurrentDir()
current contains latest files defining
the file system meta-data.public java.io.File getVersionFile()
VERSION contains the following fields:
public java.io.File getPreviousVersionFile()
VERSION from the previous directory.public java.io.File getPreviousDir()
previous contains the previous file system state,
which the system can be rolled back to.public java.io.File getPreviousTmp()
previous.tmp is a transient directory, which holds
current file system state while the new state is saved into the new
current during upgrade.
If the saving succeeds previous.tmp will be moved to
previous, otherwise it will be renamed back to
current by the recovery procedure during startup.public java.io.File getRemovedTmp()
removed.tmp is a transient directory, which holds
current file system state while the previous state is moved into
current during rollback.
If the moving succeeds removed.tmp will be removed,
otherwise it will be renamed back to
current by the recovery procedure during startup.public java.io.File getFinalizedTmp()
finalized.tmp is a transient directory, which holds
the previous file system state while it is being removed
in response to the finalize request.
Finalize operation will remove finalized.tmp when completed,
otherwise the removal will resume upon the system startup.public java.io.File getLastCheckpointTmp()
lastcheckpoint.tmp is a transient directory, which holds
current file system state while the new state is saved into the new
current during regular namespace updates.
If the saving succeeds lastcheckpoint.tmp will be moved to
previous.checkpoint, otherwise it will be renamed back to
current by the recovery procedure during startup.public java.io.File getPreviousCheckpoint()
previous.checkpoint is a directory, which holds the previous
(before the last save) state of the storage directory.
The directory is created as a reference only, it does not play role
in state recovery procedures, and is recycled automatically,
but it may be useful for manual recovery of a stale state of the system.public Storage.StorageState analyzeStorage(HdfsServerConstants.StartupOption startOpt, Storage storage) throws java.io.IOException
startOpt - a startup option.storage - The Storage object that manages this StorageDirectory.Storage.StorageState of the storage directoryInconsistentFSStateException - if directory state is not
consistent and cannot be recovered.java.io.IOExceptionpublic Storage.StorageState analyzeStorage(HdfsServerConstants.StartupOption startOpt, Storage storage, boolean checkCurrentIsEmpty) throws java.io.IOException
startOpt - a startup option.storage - The Storage object that manages this StorageDirectory.checkCurrentIsEmpty - if true, make sure current/ directory
is empty before determining to format it.Storage.StorageState of the storage directoryInconsistentFSStateException - if directory state is not
consistent and cannot be recovered.java.io.IOExceptionpublic void doRecover(Storage.StorageState curState) throws java.io.IOException
curState - specifies what/how the state should be recoveredjava.io.IOExceptionpublic boolean hasSomeData()
throws java.io.IOException
hasSomeData in interface Storage.FormatConfirmablejava.io.IOException - if the SD cannot be accessed due to an IO errorpublic boolean isShared()
public void lock()
throws java.io.IOException
Locking is not supported by all file systems. E.g., NFS does not consistently support exclusive locks.
If locking is supported we guarantee exclusive access to the storage directory. Otherwise, no guarantee is given.
java.io.IOException - if locking failspublic void unlock()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in interface Storage.FormatConfirmabletoString in class java.lang.Objectpublic boolean isLockSupported()
throws java.io.IOException
true if exclusive locks are supported or
false otherwise.java.io.IOExceptionlock()public StorageLocation getStorageLocation()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.