Package alluxio.network.protocol
Class RPCMessage
- java.lang.Object
-
- alluxio.network.protocol.RPCMessage
-
- All Implemented Interfaces:
EncodedMessage
- Direct Known Subclasses:
RPCProtoMessage
@ThreadSafe public abstract class RPCMessage extends java.lang.Object implements EncodedMessage
This is the main base class for all RPC messages to the DataServer. The message and type encoding scheme is adapted from the implementation found in the streaming server in Apache Spark.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RPCMessage.Type
The possible types of RPC messages.
-
Constructor Summary
Constructors Constructor Description RPCMessage()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static io.netty.handler.codec.ByteToMessageDecoder
createFrameDecoder()
Creates a decoder that splits up the incoming ByteBuf into new ByteBuf's according to a length field in the input.static RPCMessage
decodeMessage(RPCMessage.Type type, io.netty.buffer.ByteBuf in)
Returns the message of message type 'type', decoded from the input ByteBuf.DataBuffer
getPayloadDataBuffer()
Returns the data buffer of the payload.abstract RPCMessage.Type
getType()
Returns the type of the message.boolean
hasPayload()
Returns true if the message has a payload.void
validate()
Validates the message.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface alluxio.network.protocol.EncodedMessage
encode, getEncodedLength
-
-
-
-
Method Detail
-
getType
public abstract RPCMessage.Type getType()
Returns the type of the message.- Returns:
- the message type
-
validate
public void validate()
Validates the message. Throws an Exception if the message is invalid.
-
hasPayload
public boolean hasPayload()
Returns true if the message has a payload. The encoder will send the payload with a more efficient method.- Returns:
- true if the message has a payload, false otherwise
-
getPayloadDataBuffer
@Nullable public DataBuffer getPayloadDataBuffer()
Returns the data buffer of the payload.- Returns:
- The DataBuffer representing the payload
-
createFrameDecoder
public static io.netty.handler.codec.ByteToMessageDecoder createFrameDecoder()
Creates a decoder that splits up the incoming ByteBuf into new ByteBuf's according to a length field in the input. The encoding scheme is: [(long) frame length][message payload] The frame length is NOT included in the output ByteBuf.- Returns:
- the frame decoder for Netty
-
decodeMessage
public static RPCMessage decodeMessage(RPCMessage.Type type, io.netty.buffer.ByteBuf in)
Returns the message of message type 'type', decoded from the input ByteBuf. This must be updated to add new message types.- Parameters:
type
- The type of message to decodein
- the inputByteBuf
- Returns:
- the decoded RPCMessage
-
-