Class AbstractMessage

  • All Implemented Interfaces:
    Message
    Direct Known Subclasses:
    AckMessage, DataMessage, FailMessage, FinishMessage, PingMessage, PongMessage, StartMessage

    public abstract class AbstractMessage
    extends java.lang.Object
    implements Message
    Abstract class for messages which optionally contain sequenceNumber, partition, body.

    HugeGraph:// 0 2 3 4 +---------------------------------------------------+ 0 | magic 2byte | version 1byte | message-type 1byte | +---------------------------------------------------+ 4 | sequence-number 4byte | +---------------------------------------------------+ 8 | partition 4byte | +---------------------------------------------------+ 12 | body-length 4byte | +---------------------------------------------------+ 16 | body-content(length: body-length) | +---------------------------------------------------+

    • Constructor Detail

      • AbstractMessage

        protected AbstractMessage()
      • AbstractMessage

        protected AbstractMessage​(int sequenceNumber)
      • AbstractMessage

        protected AbstractMessage​(int sequenceNumber,
                                  int partition)
      • AbstractMessage

        protected AbstractMessage​(int sequenceNumber,
                                  NetworkBuffer body)
      • AbstractMessage

        protected AbstractMessage​(NetworkBuffer body)
      • AbstractMessage

        protected AbstractMessage​(int sequenceNumber,
                                  int partition,
                                  NetworkBuffer body)
    • Method Detail

      • encode

        public NetworkBuffer encode​(io.netty.buffer.ByteBuf buf)
        Description copied from interface: Message
        Serializes this object by writing into the given ByteBuf.
        Specified by:
        encode in interface Message
        Parameters:
        buf - ByteBuf the header buffer, if use zero-copy. Otherwise it will contain header and body.
        Returns:
        NetworkBuffer body buffer, if use zero-copy
      • encodeHeader

        protected void encodeHeader​(io.netty.buffer.ByteBuf buf)
        Only serializes the header of this message by writing into the given ByteBuf.
      • encodeBody

        protected NetworkBuffer encodeBody​(io.netty.buffer.ByteBuf buf)
        Only serializes the body of this message by writing into the given ByteBuf or return the body buffer.
      • sequenceNumber

        public int sequenceNumber()
        Description copied from interface: Message
        The message sequence number
        Specified by:
        sequenceNumber in interface Message
      • partition

        public int partition()
        Description copied from interface: Message
        The partition id
        Specified by:
        partition in interface Message
      • hasBody

        public boolean hasBody()
        Description copied from interface: Message
        Whether to include the body of the message in the same frame as the message.
        Specified by:
        hasBody in interface Message
      • body

        public NetworkBuffer body()
        Description copied from interface: Message
        An optional body for the message.
        Specified by:
        body in interface Message
      • release

        public void release()
        Description copied from interface: Message
        Release the message
        Specified by:
        release in interface Message
      • assertExtraHeader

        protected static void assertExtraHeader​(io.netty.buffer.ByteBuf buf)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object