Package alluxio.job.util
Class SerializationUtils
- java.lang.Object
-
- alluxio.job.util.SerializationUtils
-
@ThreadSafe public final class SerializationUtils extends java.lang.ObjectSerialization related utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.Serializabledeserialize(byte[] bytes)Deserializes a byte array into an object.static java.io.Serializabledeserialize(byte[] bytes, java.lang.String errorMessage)Wrapper around#deserialize(Object)which throws a runtime exception with the given message on failure.static <S,T extends java.io.Serializable>
java.util.Map<S,java.util.ArrayList<T>>makeValuesSerializable(java.util.Map<S,java.util.Collection<T>> map)static java.lang.StringparseBenchmarkResult(java.lang.String result)Parse the actual JSON result from the benchmark output.static byte[]serialize(java.lang.Object obj)Serializes an object into a byte array.static byte[]serialize(java.lang.Object obj, java.lang.String errorMessage)Wrapper aroundserialize(Object)which throws a runtime exception with the given message on failure.
-
-
-
Method Detail
-
serialize
public static byte[] serialize(java.lang.Object obj) throws java.io.IOExceptionSerializes an object into a byte array. When the object is null, returns null.- Parameters:
obj- the object to serialize- Returns:
- the serialized bytes
- Throws:
java.io.IOException- if the serialization fails
-
serialize
public static byte[] serialize(java.lang.Object obj, java.lang.String errorMessage)Wrapper aroundserialize(Object)which throws a runtime exception with the given message on failure.- Parameters:
obj- the object the serializeerrorMessage- the message to show if serialization fails- Returns:
- the serialized bytes
-
deserialize
public static java.io.Serializable deserialize(byte[] bytes) throws java.io.IOException, java.lang.ClassNotFoundExceptionDeserializes a byte array into an object. When the bytes are null, returns null.- Parameters:
bytes- the byte array to deserialize- Returns:
- the deserialized object
- Throws:
java.io.IOException- if the deserialization failsjava.lang.ClassNotFoundException- if no class found to deserialize into
-
deserialize
public static java.io.Serializable deserialize(byte[] bytes, java.lang.String errorMessage)Wrapper around#deserialize(Object)which throws a runtime exception with the given message on failure.- Parameters:
bytes- the byte array the deserializeerrorMessage- the message to show if deserialization fails- Returns:
- the deserialized object
-
makeValuesSerializable
public static <S,T extends java.io.Serializable> java.util.Map<S,java.util.ArrayList<T>> makeValuesSerializable(java.util.Map<S,java.util.Collection<T>> map)
- Type Parameters:
S- the key type for the MapT- the type of the values in the collections which are the values for the Map- Parameters:
map- a map to make serializable- Returns:
- a copy of the map with serializable values
-
parseBenchmarkResult
public static java.lang.String parseBenchmarkResult(java.lang.String result)
Parse the actual JSON result from the benchmark output. Output might contain interference logs (for example, some warn level logs indicating that the listing file time is too long).- Parameters:
result- the output of benchmark- Returns:
- the actual result in JSON format
-
-