java.io.Closeable, java.lang.AutoCloseable, StorageErrorReporter@Private public class NNStorage extends Storage implements java.io.Closeable, StorageErrorReporter
| Modifier and Type | Class | Description |
|---|---|---|
static class |
NNStorage.NameNodeDirType |
Implementation of StorageDirType specific to namenode storage
A Storage directory could be of type IMAGE which stores only fsimage,
or of type EDITS which stores edits or of type IMAGE_AND_EDITS which
stores both fsimage and edits.
|
static class |
NNStorage.NameNodeFile |
The filenames used for storing the images.
|
Storage.FormatConfirmable, Storage.StorageDirectory, Storage.StorageDirType, Storage.StorageState| Modifier and Type | Field | Description |
|---|---|---|
protected java.lang.String |
blockpoolID |
|
protected long |
mostRecentCheckpointTxId |
TxId of the last transaction that was included in the most
recent fsimage file.
|
protected java.util.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_PREVIOUS_CKPT, STORAGE_TMP_FINALIZED, STORAGE_TMP_LAST_CKPT, STORAGE_TMP_PREVIOUS, STORAGE_TMP_REMOVEDclusterID, cTime, layoutVersion, namespaceID, STORAGE_FILE_VERSION, storageType| Constructor | Description |
|---|---|
NNStorage(org.apache.hadoop.conf.Configuration conf,
java.util.Collection<java.net.URI> imageDirs,
java.util.Collection<java.net.URI> editsDirs) |
Construct the NNStorage.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
java.lang.String |
determineClusterId() |
Try to find current cluster id in the VERSION files.
|
void |
format() |
|
void |
format(NamespaceInfo nsInfo) |
Format all available storage directories.
|
void |
format(NamespaceInfo nsInfo,
boolean isRollingUpgrade) |
Format all available storage directories.
|
java.lang.String |
getBlockPoolID() |
|
static java.lang.String |
getCheckpointImageFileName(long txid) |
|
static java.io.File |
getFinalizedEditsFile(Storage.StorageDirectory sd,
long startTxId,
long endTxId) |
|
static java.lang.String |
getFinalizedEditsFileName(long startTxId,
long endTxId) |
|
java.io.File |
getFsImage(long txid,
java.util.EnumSet<NNStorage.NameNodeFile> nnfs) |
|
java.io.File |
getFsImageName(long txid) |
|
java.io.File |
getFsImageName(long txid,
NNStorage.NameNodeFile nnf) |
|
java.io.File[] |
getFsImageNameCheckpoint(long txid) |
Return the name of the image file that is uploaded by periodic
checkpointing.
|
java.io.File |
getHighestFsImageName() |
|
static java.lang.String |
getImageFileName(long txid) |
|
static java.lang.String |
getInProgressEditsFileName(long startTxId) |
|
static java.lang.String |
getLegacyOIVImageFileName(long txid) |
|
long |
getMostRecentCheckpointTxId() |
|
NamespaceInfo |
getNamespaceInfo() |
|
java.lang.String |
getNNDirectorySize() |
|
static java.lang.String |
getRollbackImageFileName(long txid) |
|
Storage.StorageDirectory |
getStorageDirectory(java.net.URI uri) |
Return the storage directory corresponding to the passed URI.
|
static java.io.File |
getTemporaryEditsFile(Storage.StorageDirectory sd,
long startTxId,
long endTxId,
long timestamp) |
|
static java.lang.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 java.lang.String |
newClusterID() |
Generate new clusterID.
|
static NamespaceInfo |
newNamespaceInfo() |
|
void |
reportErrorOnFile(java.io.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.
|
void |
setBlockPoolID(java.lang.String bpid) |
Validate and set block pool ID.
|
protected void |
setFieldsFromProperties(java.util.Properties props,
Storage.StorageDirectory sd) |
Get common storage fields.
|
protected void |
setPropertiesFromFields(java.util.Properties props,
Storage.StorageDirectory sd) |
Write version file into the storage directory.
|
void |
updateNameDirSize() |
|
void |
writeAll() |
Write all data storage files.
|
void |
writeTransactionIdFileToStorage(long txid) |
Write a small file in all available storage directories that
indicates that the namespace has reached some given transaction ID.
|
void |
writeTransactionIdFileToStorage(long txid,
NNStorage.NameNodeDirType type) |
Write a small file in all available storage directories that
indicates that the namespace has reached some given transaction ID.
|
addStorageDir, checkVersionUpgradable, confirmFormat, containsStorageDir, containsStorageDir, containsStorageDir, deleteDir, dirIterable, dirIterator, dirIterator, dirIterator, dirIterator, getBuildVersion, getFiles, getNumStorageDirs, getRegistrationID, getSingularStorageDir, getStorageDir, getStorageDirs, is203LayoutVersion, listStorageDirectories, nativeCopyFileUnbuffered, rename, unlockAll, writeProperties, writeProperties, writePropertiescheckStorageType, getClusterID, getClusterIdFromColonSeparatedString, getCTime, getLayoutVersion, getNamespaceID, getNsIdFromColonSeparatedString, getProperty, getServiceLayoutFeatureMap, getServiceLayoutVersion, readPreviousVersionProperties, readProperties, readPropertiesFile, setClusterId, setcTime, setLayoutVersion, setNamespaceID, setServiceLayoutVersion, setStorageInfo, toColonSeparatedString, toMapString, toString, versionSupportsFederationprotected java.lang.String blockpoolID
protected volatile long mostRecentCheckpointTxId
protected final java.util.List<Storage.StorageDirectory> removedStorageDirs
public NNStorage(org.apache.hadoop.conf.Configuration conf,
java.util.Collection<java.net.URI> imageDirs,
java.util.Collection<java.net.URI> editsDirs)
throws java.io.IOException
conf - Namenode configuration.imageDirs - Directories the image can be stored in.editsDirs - Directories the editlog can be stored in.java.io.IOException - if any directories are inaccessible.public boolean isPreUpgradableLayout(Storage.StorageDirectory sd) throws java.io.IOException
StorageisPreUpgradableLayout in class Storagejava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic Storage.StorageDirectory getStorageDirectory(java.net.URI uri)
uri - URI of a storage directorypublic long getMostRecentCheckpointTxId()
public void writeTransactionIdFileToStorage(long txid)
txid - the txid that has been reachedpublic void writeTransactionIdFileToStorage(long txid,
NNStorage.NameNodeDirType type)
txid - the txid that has been reachedtype - the type of directorypublic java.io.File[] getFsImageNameCheckpoint(long txid)
public java.io.File getFsImageName(long txid,
NNStorage.NameNodeFile nnf)
public java.io.File getFsImage(long txid,
java.util.EnumSet<NNStorage.NameNodeFile> nnfs)
public java.io.File getFsImageName(long txid)
public java.io.File getHighestFsImageName()
public void format(NamespaceInfo nsInfo) throws java.io.IOException
java.io.IOExceptionpublic void format(NamespaceInfo nsInfo, boolean isRollingUpgrade) throws java.io.IOException
java.io.IOExceptionpublic static NamespaceInfo newNamespaceInfo() throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic void format()
throws java.io.IOException
java.io.IOExceptionprotected void setFieldsFromProperties(java.util.Properties props,
Storage.StorageDirectory sd)
throws java.io.IOException
StorageInfosetFieldsFromProperties in class StorageInfoprops - propertiesjava.io.IOException - on errorprotected void setPropertiesFromFields(java.util.Properties props,
Storage.StorageDirectory sd)
throws java.io.IOException
setPropertiesFromFields in class Storagesd - storage directoryprops - the Properties object to write intojava.io.IOException@VisibleForTesting public static java.lang.String getCheckpointImageFileName(long txid)
@VisibleForTesting public static java.lang.String getImageFileName(long txid)
@VisibleForTesting public static java.lang.String getRollbackImageFileName(long txid)
public static java.lang.String getLegacyOIVImageFileName(long txid)
@VisibleForTesting public static java.lang.String getInProgressEditsFileName(long startTxId)
public static java.io.File getFinalizedEditsFile(Storage.StorageDirectory sd, long startTxId, long endTxId)
public static java.io.File getTemporaryEditsFile(Storage.StorageDirectory sd, long startTxId, long endTxId, long timestamp)
@VisibleForTesting
public static java.lang.String getFinalizedEditsFileName(long startTxId,
long endTxId)
public static java.lang.String getTemporaryEditsFileName(long startTxId,
long endTxId,
long timestamp)
public void reportErrorOnFile(java.io.File f)
reportErrorOnFile in interface StorageErrorReporterf - the file which had an error.public static java.lang.String newClusterID()
public java.lang.String determineClusterId()
public void setBlockPoolID(java.lang.String bpid)
public java.lang.String getBlockPoolID()
public NamespaceInfo getNamespaceInfo()
getNamespaceInfo in class Storagepublic java.lang.String getNNDirectorySize()
public void updateNameDirSize()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.