Package alluxio.grpc
Class DataMessageMarshaller<T>
- java.lang.Object
-
- alluxio.grpc.DataMessageMarshaller<T>
-
- Type Parameters:
T
- type of the message
- All Implemented Interfaces:
BufferRepository<T,DataBuffer>
,io.grpc.MethodDescriptor.Marshaller<T>
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
ReadResponseMarshaller
,WriteRequestMarshaller
public abstract class DataMessageMarshaller<T> extends java.lang.Object implements io.grpc.MethodDescriptor.Marshaller<T>, BufferRepository<T,DataBuffer>
Marshaller for data messages.
-
-
Constructor Summary
Constructors Constructor Description DataMessageMarshaller(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
Creates a data marshaller.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the repository and all its buffers.abstract T
combineData(DataMessage<T,DataBuffer> message)
Combines the data buffer into the message.protected abstract T
deserialize(io.grpc.internal.ReadableBuffer buffer)
Deserialize data buffer to the message.void
offerBuffer(DataBuffer buffer, T message)
Stores a buffer in the repository.T
parse(java.io.InputStream message)
DataBuffer
pollBuffer(T message)
Retrieves and removes a buffer from the store.protected abstract io.netty.buffer.ByteBuf[]
serialize(T message)
Serialize the message to buffers.java.io.InputStream
stream(T message)
-
-
-
Constructor Detail
-
DataMessageMarshaller
public DataMessageMarshaller(io.grpc.MethodDescriptor.Marshaller<T> originalMarshaller)
Creates a data marshaller.- Parameters:
originalMarshaller
- the original marshaller for the message
-
-
Method Detail
-
stream
public java.io.InputStream stream(T message)
- Specified by:
stream
in interfaceio.grpc.MethodDescriptor.Marshaller<T>
-
parse
public T parse(java.io.InputStream message)
- Specified by:
parse
in interfaceio.grpc.MethodDescriptor.Marshaller<T>
-
close
public void close()
Description copied from interface:BufferRepository
Closes the repository and all its buffers.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceBufferRepository<T,DataBuffer>
- Specified by:
close
in interfacejava.io.Closeable
-
offerBuffer
public void offerBuffer(DataBuffer buffer, T message)
Description copied from interface:BufferRepository
Stores a buffer in the repository.- Specified by:
offerBuffer
in interfaceBufferRepository<T,DataBuffer>
- Parameters:
buffer
- the buffer to storemessage
- the associated message
-
pollBuffer
public DataBuffer pollBuffer(T message)
Description copied from interface:BufferRepository
Retrieves and removes a buffer from the store.- Specified by:
pollBuffer
in interfaceBufferRepository<T,DataBuffer>
- Parameters:
message
- the message that associated with the buffer- Returns:
- the buffer, or null if the buffer is not found
-
combineData
public abstract T combineData(@Nullable DataMessage<T,DataBuffer> message)
Combines the data buffer into the message.- Parameters:
message
- the message to be combined- Returns:
- the message with the combined buffer
-
serialize
protected abstract io.netty.buffer.ByteBuf[] serialize(T message) throws java.io.IOException
Serialize the message to buffers.- Parameters:
message
- the message to be serialized- Returns:
- an array of
ByteBuf
s containing the serialized message - Throws:
java.io.IOException
- if the marshaller fails to serialize the message
-
deserialize
protected abstract T deserialize(io.grpc.internal.ReadableBuffer buffer) throws java.io.IOException
Deserialize data buffer to the message.- Parameters:
buffer
- the buffer that contains the message data- Returns:
- the deserialized message
- Throws:
java.io.IOException
- if the marshaller fails to deserialize the data
-
-