@InterfaceAudience.Private public class NNStorage extends Storage implements Closeable, StorageErrorReporter
Storage.FormatConfirmable, Storage.StorageDirectory, Storage.StorageDirType, Storage.StorageState
Modifier and Type | Field and Description |
---|---|
protected String |
blockpoolID |
protected long |
mostRecentCheckpointTxId
TxId of the last transaction that was included in the most
recent fsimage file.
|
protected List<Storage.StorageDirectory> |
removedStorageDirs
list of failed (and thus removed) storages
|
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_FILE_VERSION, STORAGE_PREVIOUS_CKPT, STORAGE_TMP_FINALIZED, STORAGE_TMP_LAST_CKPT, STORAGE_TMP_PREVIOUS, STORAGE_TMP_REMOVED, storageDirs, storageType
clusterID, cTime, layoutVersion, namespaceID
Constructor and Description |
---|
NNStorage(Configuration conf,
Collection<URI> imageDirs,
Collection<URI> editsDirs)
Construct the NNStorage.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
determineClusterId()
try to find current cluster id in the VERSION files
returns first cluster id found in any VERSION file
null in case none found
|
void |
format() |
void |
format(NamespaceInfo nsInfo)
Format all available storage directories.
|
String |
getBlockPoolID() |
static String |
getCheckpointImageFileName(long txid) |
static String |
getFinalizedEditsFileName(long startTxId,
long endTxId) |
File |
getFsImageName(long txid)
Return the name of the image file.
|
File[] |
getFsImageNameCheckpoint(long txid)
Return the name of the image file that is uploaded by periodic
checkpointing
|
File |
getHighestFsImageName() |
static String |
getImageFileName(long txid) |
static String |
getInProgressEditsFileName(long startTxId) |
long |
getMostRecentCheckpointTxId() |
NamespaceInfo |
getNamespaceInfo() |
static String |
getTemporaryEditsFileName(long startTxId,
long endTxId,
long timestamp) |
boolean |
isPreUpgradableLayout(Storage.StorageDirectory sd)
Return 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.
|
static String |
newClusterID()
Generate new clusterID.
|
static NamespaceInfo |
newNamespaceInfo() |
void |
reportErrorOnFile(File f)
Report that an IOE has occurred on some file which may
or may not be within one of the NN image storage directories.
|
protected void |
setFieldsFromProperties(Properties props,
Storage.StorageDirectory sd)
Get common storage fields.
|
protected void |
setPropertiesFromFields(Properties props,
Storage.StorageDirectory sd)
Write version file into the storage directory.
|
void |
writeTransactionIdFileToStorage(long txid)
Write a small file in all available storage directories that
indicates that the namespace has reached some given transaction ID.
|
addStorageDir, checkVersionUpgradable, confirmFormat, deleteDir, dirIterable, dirIterator, dirIterator, getBuildVersion, getFiles, getNumStorageDirs, getRegistrationID, getSingularStorageDir, getStorageDir, is203LayoutVersion, listStorageDirectories, readPreviousVersionProperties, readProperties, readPropertiesFile, rename, setClusterId, setcTime, setLayoutVersion, setNamespaceID, setStorageType, unlockAll, writeAll, writeProperties, writeProperties
getClusterID, getCTime, getLayoutVersion, getNamespaceID, setStorageInfo, toColonSeparatedString, toString, versionSupportsFederation
protected String blockpoolID
protected long mostRecentCheckpointTxId
protected final List<Storage.StorageDirectory> removedStorageDirs
public NNStorage(Configuration conf, Collection<URI> imageDirs, Collection<URI> editsDirs) throws IOException
conf
- Namenode configuration.imageDirs
- Directories the image can be stored in.editsDirs
- Directories the editlog can be stored in.IOException
- if any directories are inaccessible.public boolean isPreUpgradableLayout(Storage.StorageDirectory sd) throws IOException
Storage
isPreUpgradableLayout
in class Storage
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public long getMostRecentCheckpointTxId()
public void writeTransactionIdFileToStorage(long txid)
txid
- the txid that has been reachedpublic File[] getFsImageNameCheckpoint(long txid)
public File getFsImageName(long txid)
public File getHighestFsImageName()
public void format(NamespaceInfo nsInfo) throws IOException
IOException
public static NamespaceInfo newNamespaceInfo() throws UnknownHostException
UnknownHostException
public void format() throws IOException
IOException
protected void setFieldsFromProperties(Properties props, Storage.StorageDirectory sd) throws IOException
Storage
setFieldsFromProperties
in class Storage
IOException
protected void setPropertiesFromFields(Properties props, Storage.StorageDirectory sd) throws IOException
setPropertiesFromFields
in class Storage
sd
- storage directoryprops
- the Properties object to write intoIOException
public static String getCheckpointImageFileName(long txid)
public static String getImageFileName(long txid)
public static String getInProgressEditsFileName(long startTxId)
public static String getFinalizedEditsFileName(long startTxId, long endTxId)
public static String getTemporaryEditsFileName(long startTxId, long endTxId, long timestamp)
public void reportErrorOnFile(File f)
reportErrorOnFile
in interface StorageErrorReporter
f
- the file which had an error.public static String newClusterID()
public String determineClusterId()
public String getBlockPoolID()
public NamespaceInfo getNamespaceInfo()
Copyright © 2013 Apache Software Foundation. All rights reserved.