构造器和说明 |
---|
Storage.StorageDirectory(File dir) |
Storage.StorageDirectory(File dir,
Storage.StorageDirType dirType) |
限定符和类型 | 方法和说明 |
---|---|
Storage.StorageState |
analyzeStorage(HdfsConstants.StartupOption startOpt)
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. |
void |
lock()
Lock storage to provide exclusive access.
|
void |
read()
Read version file.
|
void |
read(File from) |
void |
unlock()
Unlock storage.
|
void |
write()
Write version file.
|
void |
write(File to) |
public Storage.StorageDirectory(File dir)
public Storage.StorageDirectory(File dir, Storage.StorageDirType dirType)
public File getRoot()
public Storage.StorageDirType getStorageDirType()
public void read() throws IOException
IOException
- if file cannot be read or contains inconsistent datapublic void read(File from) throws IOException
IOException
public void write() throws IOException
IOException
public void write(File to) throws IOException
IOException
public 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.
IOException
public 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(HdfsConstants.StartupOption startOpt) throws IOException
startOpt
- a startup option.Storage.StorageState
of the storage directoryInconsistentFSStateException
- if directory state is not
consistent and cannot be recovered.IOException
public void doRecover(Storage.StorageState curState) throws IOException
curState
- specifies what/how the state should be recoveredIOException
public 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 exculsive access to the storage directory. Otherwise, no guarantee is given.
IOException
- if locking failspublic void unlock() throws IOException
IOException
Copyright © 2009 The Apache Software Foundation