Package org.apache.hadoop.ozone.om
Class OMStorage
java.lang.Object
org.apache.hadoop.ozone.common.Storage
org.apache.hadoop.ozone.om.OMStorage
public class OMStorage
extends org.apache.hadoop.ozone.common.Storage
Ozone Manager VERSION file representation.
On top of what is defined in the base Storage class, this class adds
functionality to hold Ozone Manager related data in its VERSION file.
The additional values stored:
- Ozone Manager ID - a UUID that identifies this Ozone Manager.
The value can not be changed once initialized, and
it is initialized automatically in this class.
The value itself is not used anymore, it is part of the
.OzoneManagerDetailsProto hence not removed yet.
- Ozone Manager Node Id - the node id defined for this Ozone manager in the
configuration. The value can not be changed after
it was set.
- Ozone Manager Certificate Serial Id - the serial id of the Ozone Manager's
SSL certificate if one exists.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.ozone.common.Storage
org.apache.hadoop.ozone.common.Storage.StorageState -
Field Summary
FieldsFields inherited from class org.apache.hadoop.ozone.common.Storage
CONTAINER_DIR, STORAGE_DIR_CURRENT, STORAGE_FILE_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionOMStorage(org.apache.hadoop.hdds.conf.OzoneConfiguration conf) Construct the OMStorage instance based on the configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertiesRetrieves the serial id of certificate issued by SCM.static FilegetOmDbDir(org.apache.hadoop.hdds.conf.ConfigurationSource conf) From the provided configuration gets the directory that Ozone Manager should use to store its metadata.getOmId()Retrieves the OM ID from the version file.Retrieves the OM NodeId from the version file.voidsetOmCertSerialId(String certSerialId) Sets the certificate serial id to be stored in the VERSION file representation.voidSet's the Ozone Manager ID to be stored in the VERSION file representation.voidsetOmNodeId(String nodeId) Set's the Ozone Manager Node ID.voidRemoves the certificate serial id from the VERSION file representation.voidvalidateOrPersistOmNodeId(String expectedNodeId) Validates if the provided value is the one saved in the VERSION file.Methods inherited from class org.apache.hadoop.ozone.common.Storage
forceInitialize, getClusterID, getCreationTime, getCurrentDir, getFirstUpgradeActionLayoutVersion, getInitLayoutVersion, getLayoutVersion, getNodeType, getState, getStorageDir, getStorageInfo, getVersionFile, initialize, persistCurrentState, setClusterId, setFirstUpgradeActionLayoutVersion, setLayoutVersion
-
Field Details
-
TESTING_INIT_LAYOUT_VERSION_KEY
- See Also:
-
-
Constructor Details
-
OMStorage
Construct the OMStorage instance based on the configuration. The parent directory used by the storage is defined by theOMConfigKeys.OZONE_OM_DB_DIRSproperty, if that is not set theHddsConfigKeys.OZONE_METADATA_DIRSproperty value is used as a fallback. If none of these are defined in the configuration an IllegalArgumentException is being thrown.- Parameters:
conf- an OzoneConfiguration instance containing the properties that can define the path where Ozone Manager stores its metadata- Throws:
IOException- if any directories are inaccessible.IllegalArgumentException- if the configuration does not specify the path where the metadata should be stored
-
-
Method Details
-
setOmCertSerialId
Sets the certificate serial id to be stored in the VERSION file representation. Note that, to change the VERSION file itself,Storage.persistCurrentState()has to be called after this method.- Parameters:
certSerialId- the new certificate serial id to set- Throws:
IOException- if the current VERSION file is not readable
-
unsetOmCertSerialId
public void unsetOmCertSerialId()Removes the certificate serial id from the VERSION file representation. Note that, to change the VERSION file itself,Storage.persistCurrentState()has to be called after this method. -
setOmId
Set's the Ozone Manager ID to be stored in the VERSION file representation. Note that, to change the VERSION file itself,Storage.persistCurrentState()has to be called after this method.- Parameters:
omId- the UUID that identifies this Ozone Manager as a String- Throws:
IOException- if the Storage representation is already initialized, as this property can not be changed once it has been set and stored
-
setOmNodeId
Set's the Ozone Manager Node ID. This value should be set based on the configuration and should not be changed later on neither in the configuration nor in the VERSION file to ensure consistency within the Ozone Manager HA peers. Note that, to change the VERSION file itself,Storage.persistCurrentState()has to be called after this method.- Parameters:
nodeId- the UUID that identifies this Ozone Manager as a String- Throws:
IOException- if the Storage representation is already initialized, as this property can not be changed once it has been set and stored.
-
validateOrPersistOmNodeId
Validates if the provided value is the one saved in the VERSION file. This method provides a convenience to check if the configured value and the one that was stored in the VERSION file are matching. As a VERSION file that was created by an older version of OM might not contain the value, if the VERSION file does not have this property, the method persists the provided expectedNodeId into the VERSION file and skips the validation.- Parameters:
expectedNodeId- the nodeId read from configuration, that has to be matched against what we have saved in the VERSION file- Throws:
IOException- - if the VERSION file is not present at the time of the call - if the VERSION file contains a different value than the expectedNodeId provided - if reading/writing the VERSION file fails
-
getOmId
Retrieves the OM ID from the version file.- Returns:
- the stored OM ID
-
getOmNodeId
Retrieves the OM NodeId from the version file.- Returns:
- the stored OM Node ID
-
getOmCertSerialId
Retrieves the serial id of certificate issued by SCM.- Returns:
- the stored Certificate Serial ID
-
getNodeProperties
- Specified by:
getNodePropertiesin classorg.apache.hadoop.ozone.common.Storage
-
getOmDbDir
From the provided configuration gets the directory that Ozone Manager should use to store its metadata. The value ofOMConfigKeys.OZONE_OM_DB_DIRSproperty is returned as the primary value, if that is not set, the method falls back to theHddsConfigKeys.OZONE_METADATA_DIRSproperty. If none of these are defined, an IllegalArgumentException is being thrown.- Parameters:
conf- - the configuration to get the properties from- Returns:
- The metadata directory path, that should be used by OM, after creating all the necessary directories
- Throws:
IllegalArgumentException- if the metadata directory can not be determined from the configuration
-