Class StateStoreSerializer

java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreSerializer
Direct Known Subclasses:
StateStoreSerializerPBImpl

public abstract class StateStoreSerializer extends Object
Serializer to store and retrieve data in the State Store.
  • Constructor Details

    • StateStoreSerializer

      public StateStoreSerializer()
  • Method Details

    • getSerializer

      public static StateStoreSerializer getSerializer()
      Get the default serializer based.
      Returns:
      Singleton serializer.
    • getSerializer

      public static StateStoreSerializer getSerializer(org.apache.hadoop.conf.Configuration conf)
      Get a serializer based on the provided configuration.
      Parameters:
      conf - Configuration. Default if null.
      Returns:
      Singleton serializer.
    • newRecord

      public static <T> T newRecord(Class<T> clazz)
      Create a new record.
      Type Parameters:
      T - Type of the record.
      Parameters:
      clazz - Class of the new record.
      Returns:
      New record.
    • newRecordInstance

      public abstract <T> T newRecordInstance(Class<T> clazz)
      Create a new record.
      Type Parameters:
      T - Type of the record.
      Parameters:
      clazz - Class of the new record.
      Returns:
      New record.
    • serialize

      public abstract byte[] serialize(BaseRecord record)
      Serialize a record into a byte array.
      Parameters:
      record - Record to serialize.
      Returns:
      Byte array with the serialized record.
    • serializeString

      public abstract String serializeString(BaseRecord record)
      Serialize a record into a string.
      Parameters:
      record - Record to serialize.
      Returns:
      String with the serialized record.
    • deserialize

      public abstract <T extends BaseRecord> T deserialize(byte[] byteArray, Class<T> clazz) throws IOException
      Deserialize a bytes array into a record.
      Type Parameters:
      T - Type of the record.
      Parameters:
      byteArray - Byte array to deserialize.
      clazz - Class of the record.
      Returns:
      New record.
      Throws:
      IOException - If it cannot deserialize the record.
    • deserialize

      public abstract <T extends BaseRecord> T deserialize(String data, Class<T> clazz) throws IOException
      Deserialize a string into a record.
      Type Parameters:
      T - Type of the record.
      Parameters:
      data - String with the data to deserialize.
      clazz - Class of the record.
      Returns:
      New record.
      Throws:
      IOException - If it cannot deserialize the record.