Class StorageInfo
java.lang.Object
org.apache.hadoop.hdfs.server.common.StorageInfo
- Direct Known Subclasses:
CheckpointSignature,NamenodeRegistration,NamespaceInfo,Storage
Common class for storage information.
TODO namespaceID should be long and computed as hash(address + port)
-
Field Summary
FieldsModifier and TypeFieldDescriptionlongintintprotected static final Stringprotected final HdfsServerConstants.NodeType -
Constructor Summary
ConstructorsConstructorDescriptionStorageInfo(int layoutV, int nsID, String cid, long cT, HdfsServerConstants.NodeType type) StorageInfo(StorageInfo from) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckStorageType(Properties props, Storage.StorageDirectory sd) Validate and set storage type fromPropertiescluster id of the file system.static StringlonggetCTime()Creation time of the file system state.intLayout version of the storage data.intNamespace id of the file system.static intprotected static StringgetProperty(Properties props, Storage.StorageDirectory sd, String name) intvoidRead properties from the the previous/VERSION file in the given storage directory.voidRead properties from the VERSION file in the given storage directory.static PropertiesreadPropertiesFile(File from) protected voidsetClusterId(Properties props, int layoutVersion, Storage.StorageDirectory sd) Validate and set clusterId fromPropertiesprotected voidsetcTime(Properties props, Storage.StorageDirectory sd) Validate and set ctime fromPropertiesprotected voidGet common storage fields.protected voidsetLayoutVersion(Properties props, Storage.StorageDirectory sd) Validate and set layout version fromPropertiesprotected voidsetNamespaceID(Properties props, Storage.StorageDirectory sd) Validate and set namespaceID version fromPropertiesvoidsetServiceLayoutVersion(int lv) voidsetStorageInfo(StorageInfo from) Returns string representation of Storage info attributes stored in Map.toString()boolean
-
Field Details
-
layoutVersion
public int layoutVersion -
namespaceID
public int namespaceID -
clusterID
-
cTime
public long cTime -
storageType
-
STORAGE_FILE_VERSION
- See Also:
-
-
Constructor Details
-
StorageInfo
-
StorageInfo
-
StorageInfo
-
-
Method Details
-
getLayoutVersion
public int getLayoutVersion()Layout version of the storage data. -
getNamespaceID
public int getNamespaceID()Namespace id of the file system.Assigned to the file system at formatting and never changes after that. Shared by all file system components.
-
getClusterID
cluster id of the file system. -
getCTime
public long getCTime()Creation time of the file system state.Modified during upgrades.
-
setStorageInfo
-
versionSupportsFederation
-
toString
-
toMapString
Returns string representation of Storage info attributes stored in Map.- Returns:
- string representation of storage info attributes.
-
toColonSeparatedString
-
getNsIdFromColonSeparatedString
-
getClusterIdFromColonSeparatedString
-
readProperties
Read properties from the VERSION file in the given storage directory.- Throws:
IOException
-
readPreviousVersionProperties
Read properties from the the previous/VERSION file in the given storage directory.- Throws:
IOException
-
setFieldsFromProperties
protected void setFieldsFromProperties(Properties props, Storage.StorageDirectory sd) throws IOException Get common storage fields. Should be overloaded if additional fields need to be get.- Parameters:
props- properties- Throws:
IOException- on error
-
checkStorageType
protected void checkStorageType(Properties props, Storage.StorageDirectory sd) throws InconsistentFSStateException Validate and set storage type fromProperties- Throws:
InconsistentFSStateException
-
setcTime
protected void setcTime(Properties props, Storage.StorageDirectory sd) throws InconsistentFSStateException Validate and set ctime fromProperties- Throws:
InconsistentFSStateException
-
setClusterId
protected void setClusterId(Properties props, int layoutVersion, Storage.StorageDirectory sd) throws InconsistentFSStateException Validate and set clusterId fromProperties- Throws:
InconsistentFSStateException
-
setLayoutVersion
protected void setLayoutVersion(Properties props, Storage.StorageDirectory sd) throws IncorrectVersionException, InconsistentFSStateException Validate and set layout version fromProperties -
setNamespaceID
protected void setNamespaceID(Properties props, Storage.StorageDirectory sd) throws InconsistentFSStateException Validate and set namespaceID version fromProperties- Throws:
InconsistentFSStateException
-
setServiceLayoutVersion
public void setServiceLayoutVersion(int lv) -
getServiceLayoutVersion
public int getServiceLayoutVersion() -
getServiceLayoutFeatureMap
-
getProperty
protected static String getProperty(Properties props, Storage.StorageDirectory sd, String name) throws InconsistentFSStateException - Throws:
InconsistentFSStateException
-
readPropertiesFile
- Throws:
IOException
-