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

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class org.apache.hadoop.ozone.common.Storage

    CONTAINER_DIR, STORAGE_DIR_CURRENT, STORAGE_FILE_VERSION
  • Constructor Summary

    Constructors
    Constructor
    Description
    OMStorage(org.apache.hadoop.hdds.conf.OzoneConfiguration conf)
    Construct the OMStorage instance based on the configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Properties
     
    Retrieves the serial id of certificate issued by SCM.
    static File
    getOmDbDir(org.apache.hadoop.hdds.conf.ConfigurationSource conf)
    From the provided configuration gets the directory that Ozone Manager should use to store its metadata.
    Retrieves the OM ID from the version file.
    Retrieves the OM NodeId from the version file.
    void
    setOmCertSerialId(String certSerialId)
    Sets the certificate serial id to be stored in the VERSION file representation.
    void
    Set's the Ozone Manager ID to be stored in the VERSION file representation.
    void
    Set's the Ozone Manager Node ID.
    void
    Removes the certificate serial id from the VERSION file representation.
    void
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OMStorage

      public OMStorage(org.apache.hadoop.hdds.conf.OzoneConfiguration conf) throws IOException
      Construct the OMStorage instance based on the configuration. The parent directory used by the storage is defined by the OMConfigKeys.OZONE_OM_DB_DIRS property, if that is not set the HddsConfigKeys.OZONE_METADATA_DIRS property 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

      public void setOmCertSerialId(String certSerialId) throws IOException
      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

      public void setOmId(String omId) throws IOException
      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

      public void setOmNodeId(String nodeId) throws IOException
      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

      public void validateOrPersistOmNodeId(String expectedNodeId) throws IOException
      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

      public String getOmId()
      Retrieves the OM ID from the version file.
      Returns:
      the stored OM ID
    • getOmNodeId

      public String getOmNodeId()
      Retrieves the OM NodeId from the version file.
      Returns:
      the stored OM Node ID
    • getOmCertSerialId

      public String getOmCertSerialId()
      Retrieves the serial id of certificate issued by SCM.
      Returns:
      the stored Certificate Serial ID
    • getNodeProperties

      protected Properties getNodeProperties()
      Specified by:
      getNodeProperties in class org.apache.hadoop.ozone.common.Storage
    • getOmDbDir

      public static File getOmDbDir(org.apache.hadoop.hdds.conf.ConfigurationSource conf)
      From the provided configuration gets the directory that Ozone Manager should use to store its metadata. The value of OMConfigKeys.OZONE_OM_DB_DIRS property is returned as the primary value, if that is not set, the method falls back to the HddsConfigKeys.OZONE_METADATA_DIRS property. 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