@InterfaceAudience.Private public static class Storage.StorageDirectory extends Object implements Storage.FormatConfirmable
| Constructor and Description |
|---|
Storage.StorageDirectory(File dir) |
Storage.StorageDirectory(File dir,
Storage.StorageDirType dirType) |
Storage.StorageDirectory(File dir,
Storage.StorageDirType dirType,
boolean useLock)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
Storage.StorageState |
analyzeStorage(HdfsServerConstants.StartupOption startOpt,
Storage storage)
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.
|
File |
getCurrentDir()
Directory
current contains latest files defining
the file system meta-data. |
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. |
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. |
File |
getPreviousCheckpoint()
previous.checkpoint is a directory, which holds the previous
(before the last save) state of the storage directory. |
File |
getPreviousDir()
Directory
previous contains the previous file system state,
which the system can be rolled back to. |
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. |
File |
getPreviousVersionFile()
File
VERSION from the previous directory. |
File |
getRemovedTmp()
removed.tmp is a transient directory, which holds
current file system state while the previous state is moved into
current during rollback. |
File |
getRoot()
Get root directory of this storage
|
Storage.StorageDirType |
getStorageDirType()
Get storage directory type
|
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.
|
void |
lock()
Lock storage to provide exclusive access.
|
void |
read(File from,
Storage storage) |
String |
toString() |
void |
unlock()
Unlock storage.
|
public Storage.StorageDirectory(File dir)
public Storage.StorageDirectory(File dir, Storage.StorageDirType dirType)
public Storage.StorageDirectory(File dir, Storage.StorageDirType dirType, boolean useLock)
dir - directory corresponding to the storagedirType - storage directory typeuseLock - true - enables locking on the storage directory and false
disables lockingpublic File getRoot()
public Storage.StorageDirType getStorageDirType()
public void read(File from, Storage storage) throws IOException
IOExceptionpublic void clearDirectory()
throws 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.
IOExceptionpublic File getCurrentDir()
current contains latest files defining
the file system meta-data.public File getVersionFile()
VERSION contains the following fields:
public File getPreviousVersionFile()
VERSION from the previous directory.public File getPreviousDir()
previous contains the previous file system state,
which the system can be rolled back to.public 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 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 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 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 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 IOException
startOpt - a startup option.Storage.StorageState of the storage directoryInconsistentFSStateException - if directory state is not
consistent and cannot be recovered.IOExceptionpublic void doRecover(Storage.StorageState curState) throws IOException
curState - specifies what/how the state should be recoveredIOExceptionpublic boolean hasSomeData()
throws IOException
hasSomeData in interface Storage.FormatConfirmableIOException - if the SD cannot be accessed due to an IO errorpublic void lock()
throws 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.
IOException - if locking failspublic void unlock()
throws IOException
IOExceptionpublic String toString()
toString in interface Storage.FormatConfirmabletoString in class Objectpublic boolean isLockSupported()
throws IOException
true if exclusive locks are supported or
false otherwise.IOExceptionlock()Copyright © 2013 Apache Software Foundation. All rights reserved.