public abstract class Storage extends StorageInfo
Local storage information is stored in a separate file VERSION. It contains type of the node, the storage layout version, the namespace id, and the fs state creation time.
Local storage can reside in multiple directories. Each directory should contain the same VERSION file as the others. During startup Hadoop servers (name-node and data-nodes) read their local storage information from them.
The servers hold a lock for each storage directory while they run so that other nodes were not able to startup sharing the same storage. The locks are released when the servers stop (normally or abnormally).
限定符和类型 | 类和说明 |
---|---|
class |
Storage.StorageDirectory
One of the storage directories.
|
static interface |
Storage.StorageDirType
An interface to denote storage directory type
Implementations can define a type for storage directory by implementing
this interface.
|
static class |
Storage.StorageState |
限定符和类型 | 字段和说明 |
---|---|
protected static int |
LAST_PRE_UPGRADE_LAYOUT_VERSION |
protected static String |
LAST_UPGRADABLE_HADOOP_VERSION |
static int |
LAST_UPGRADABLE_LAYOUT_VERSION |
static int[] |
LAYOUT_VERSIONS_203
Layout versions of 203 release
|
static org.apache.commons.logging.Log |
LOG |
static int |
PRE_GENERATIONSTAMP_LAYOUT_VERSION |
static String |
STORAGE_DIR_CURRENT |
protected static String |
STORAGE_FILE_VERSION |
protected List<Storage.StorageDirectory> |
storageDirs |
cTime, layoutVersion, namespaceID
限定符 | 构造器和说明 |
---|---|
protected |
Storage(HdfsConstants.NodeType type)
Create empty storage info of the specified type
|
protected |
Storage(HdfsConstants.NodeType type,
int nsID,
long cT) |
protected |
Storage(HdfsConstants.NodeType type,
StorageInfo storageInfo) |
限定符和类型 | 方法和说明 |
---|---|
protected void |
addStorageDir(Storage.StorageDirectory sd) |
protected static void |
checkVersionUpgradable(int oldVersion)
Checks if the upgrade from the given old version is supported.
|
protected abstract void |
corruptPreUpgradeStorage(File rootDir) |
protected static void |
deleteDir(File dir) |
Iterator<Storage.StorageDirectory> |
dirIterator()
Return default iterator
This iterator returns all entires of storageDirs
|
Iterator<Storage.StorageDirectory> |
dirIterator(Storage.StorageDirType dirType)
Return iterator based on Storage Directory Type
This iterator selects entires of storageDirs of type dirType and returns
them via the Iterator
|
protected void |
getFields(Properties props,
Storage.StorageDirectory sd)
Get common storage fields.
|
int |
getNumStorageDirs() |
static String |
getRegistrationID(StorageInfo storage) |
Storage.StorageDirectory |
getStorageDir(int idx) |
static boolean |
is203LayoutVersion(int layoutVersion) |
abstract boolean |
isConversionNeeded(Storage.StorageDirectory sd) |
boolean |
isLockSupported(int idx)
Check whether underlying file system supports file locking.
|
static void |
rename(File from,
File to) |
protected void |
setFields(Properties props,
Storage.StorageDirectory sd)
Set common storage fields.
|
void |
unlockAll()
Unlock all storage directories.
|
void |
writeAll()
Write all data storage files.
|
protected void |
writeCorruptedData(RandomAccessFile file) |
getCTime, getLayoutVersion, getNamespaceID, setStorageInfo
public static final org.apache.commons.logging.Log LOG
protected static final int LAST_PRE_UPGRADE_LAYOUT_VERSION
public static final int LAST_UPGRADABLE_LAYOUT_VERSION
protected static final String LAST_UPGRADABLE_HADOOP_VERSION
public static final int PRE_GENERATIONSTAMP_LAYOUT_VERSION
public static final int[] LAYOUT_VERSIONS_203
protected List<Storage.StorageDirectory> storageDirs
protected Storage(HdfsConstants.NodeType type)
protected Storage(HdfsConstants.NodeType type, int nsID, long cT)
protected Storage(HdfsConstants.NodeType type, StorageInfo storageInfo)
public Iterator<Storage.StorageDirectory> dirIterator()
public Iterator<Storage.StorageDirectory> dirIterator(Storage.StorageDirType dirType)
public int getNumStorageDirs()
public Storage.StorageDirectory getStorageDir(int idx)
protected void addStorageDir(Storage.StorageDirectory sd)
public abstract boolean isConversionNeeded(Storage.StorageDirectory sd) throws IOException
IOException
protected static void checkVersionUpgradable(int oldVersion) throws IOException
oldVersion
- IOException
protected void getFields(Properties props, Storage.StorageDirectory sd) throws IOException
props
- IOException
protected void setFields(Properties props, Storage.StorageDirectory sd) throws IOException
props
- IOException
public static void rename(File from, File to) throws IOException
IOException
protected static void deleteDir(File dir) throws IOException
IOException
public void writeAll() throws IOException
IOException
public void unlockAll() throws IOException
IOException
public boolean isLockSupported(int idx) throws IOException
true
if exclusive locks are supported or
false
otherwise.IOException
Storage.StorageDirectory.lock()
public static String getRegistrationID(StorageInfo storage)
protected abstract void corruptPreUpgradeStorage(File rootDir) throws IOException
IOException
protected void writeCorruptedData(RandomAccessFile file) throws IOException
IOException
public static boolean is203LayoutVersion(int layoutVersion)
Copyright © 2009 The Apache Software Foundation