Class StateStoreSerializer
java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreSerializer
- Direct Known Subclasses:
StateStoreSerializerPBImpl
Serializer to store and retrieve data in the State Store.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <T extends BaseRecord>
Tdeserialize(byte[] byteArray, Class<T> clazz) Deserialize a bytes array into a record.abstract <T extends BaseRecord>
Tdeserialize(String data, Class<T> clazz) Deserialize a string into a record.static StateStoreSerializerGet the default serializer based.static StateStoreSerializergetSerializer(org.apache.hadoop.conf.Configuration conf) Get a serializer based on the provided configuration.static <T> TCreate a new record.abstract <T> TnewRecordInstance(Class<T> clazz) Create a new record.abstract byte[]serialize(BaseRecord record) Serialize a record into a byte array.abstract StringserializeString(BaseRecord record) Serialize a record into a string.
-
Constructor Details
-
StateStoreSerializer
public StateStoreSerializer()
-
-
Method Details
-
getSerializer
Get the default serializer based.- Returns:
- Singleton serializer.
-
getSerializer
Get a serializer based on the provided configuration.- Parameters:
conf- Configuration. Default if null.- Returns:
- Singleton serializer.
-
newRecord
Create a new record.- Type Parameters:
T- Type of the record.- Parameters:
clazz- Class of the new record.- Returns:
- New record.
-
newRecordInstance
Create a new record.- Type Parameters:
T- Type of the record.- Parameters:
clazz- Class of the new record.- Returns:
- New record.
-
serialize
Serialize a record into a byte array.- Parameters:
record- Record to serialize.- Returns:
- Byte array with the serialized record.
-
serializeString
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.
-