StateStoreSerializableImpl (Apache Hadoop HDFS-RBF 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.federation.store.driver.impl, class: StateStoreSerializableImpl

Package org.apache.hadoop.hdfs.server.federation.store.driver.impl

# Class StateStoreSerializableImpl

java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver
org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreBaseImpl
org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreSerializableImpl

All Implemented Interfaces:
  `StateStoreRecordOperations`

Direct Known Subclasses:
  `StateStoreFileBaseImpl`, `StateStoreMySQLImpl`, `StateStoreZooKeeperImpl`

@Public @Evolving public abstract class StateStoreSerializableImpl extends StateStoreBaseImpl
State Store driver that stores a serialization of the records. The serializer is pluggable.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final String`
  `COLON_MARK`
  Mark for colon in path names.
  `protected static final String`
  `SLASH_MARK`
  Mark for slashes in path names.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StateStoreSerializableImpl()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected static String`
  `getOriginalPrimaryKey(String stateStoreRecordKey)`
  Get the original primary key for the given state store record key.
  `protected static String`
  `getPrimaryKey(BaseRecord record)`
  Get the primary key for a record.
  `boolean`
  `init(org.apache.hadoop.conf.Configuration config, String id, Collection<Class<? extends BaseRecord>> records, StateStoreMetrics metrics)`
  Initialize the state store connection.
  `protected <T extends BaseRecord>
  T`
  `newRecord(String data, Class<T> clazz, boolean includeDates)`
  Creates a record from an input data string.
  `protected <T extends BaseRecord>
  byte[]`
  `serialize(T record)`
  Serialize a record using the serializer.
  `protected <T extends BaseRecord>
  String`
  `serializeString(T record)`
  Serialize a record using the serializer.

  ### Methods inherited from class org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreBaseImpl

  `get, getMultiple, put, remove, remove, removeMultiple`

  ### Methods inherited from class org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver

  `close, getConf, getIdentifier, getMetrics, getTime, handleOverwriteAndDelete, initDriver, initRecordStorage, isDriverReady, verifyDriverReady`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreRecordOperations

  `get, putAll, remove, removeAll`

- ## Field Details

  - ### SLASH_MARK

    protected static final String SLASH_MARK
    Mark for slashes in path names.
    See Also:
      - Constant Field Values

  - ### COLON_MARK

    protected static final String COLON_MARK
    Mark for colon in path names.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### StateStoreSerializableImpl

    public StateStoreSerializableImpl()

- ## Method Details

  - ### init

    public boolean init(org.apache.hadoop.conf.Configuration config, String id, Collection<Class<? extends BaseRecord>> records, StateStoreMetrics metrics)
    Description copied from class: `StateStoreDriver`
    Initialize the state store connection.
    Overrides:
      `init` in class `StateStoreDriver`
    Parameters:
      `config` - Configuration for the driver.
      `id` - Identifier for the driver.
      `records` - Records that are supported.
      `metrics` - State store metrics.
    Returns:
      If initialized and ready, false if failed to initialize driver.

  - ### serialize

    protected <T extends BaseRecord> byte[] serialize(T record)
    Serialize a record using the serializer.
    Type Parameters:
      `T` - Type of the state store record.
    Parameters:
      `record` - Record to serialize.
    Returns:
      Byte array with the serialization of the record.

  - ### serializeString

    protected <T extends BaseRecord> String serializeString(T record)
    Serialize a record using the serializer.
    Type Parameters:
      `T` - Type of the state store record.
    Parameters:
      `record` - Record to serialize.
    Returns:
      String with the serialization of the record.

  - ### newRecord

    protected <T extends BaseRecord> T newRecord(String data, Class<T> clazz, boolean includeDates) throws IOException
    Creates a record from an input data string.
    Type Parameters:
      `T` - Type of the state store record.
    Parameters:
      `data` - Serialized text of the record.
      `clazz` - Record class.
      `includeDates` - If dateModified and dateCreated are serialized.
    Returns:
      The created record by deserializing the input text.
    Throws:
      `IOException` - If the record deserialization fails.

  - ### getPrimaryKey

    protected static String getPrimaryKey(BaseRecord record)
    Get the primary key for a record. If we don't want to store in folders, we need to remove / from the name.
    Parameters:
      `record` - Record to get the primary key for.
    Returns:
      Primary key for the record.

  - ### getOriginalPrimaryKey

    protected static String getOriginalPrimaryKey(String stateStoreRecordKey)
    Get the original primary key for the given state store record key. The returned key is readable as it is the original key.
    Parameters:
      `stateStoreRecordKey` - The record primary key stored by the state store implementations.
    Returns:
      The original primary key for the given record key.