Class 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.
    • Constructor Detail

      • RPCMessage

        public RPCMessage()
    • 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 decode
        in - the input ByteBuf
        Returns:
        the decoded RPCMessage