Class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMessage>

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Direct Known Subclasses:
BinaryMemcacheRequestDecoder, BinaryMemcacheResponseDecoder

@UnstableApi public abstract class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMessage> extends AbstractMemcacheObjectDecoder
Decoder for both BinaryMemcacheRequest and BinaryMemcacheResponse.

The difference in the protocols (header) is implemented by the subclasses.

  • Field Details

  • Constructor Details

    • AbstractBinaryMemcacheDecoder

      protected AbstractBinaryMemcacheDecoder()
      Create a new AbstractBinaryMemcacheDecoder with default settings.
    • AbstractBinaryMemcacheDecoder

      protected AbstractBinaryMemcacheDecoder(int chunkSize)
      Create a new AbstractBinaryMemcacheDecoder with custom settings.
      Parameters:
      chunkSize - the maximum chunk size of the payload.
  • Method Details

    • decode

      protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
      Description copied from class: ByteToMessageDecoder
      Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.
      Specified by:
      decode in class ByteToMessageDecoder
      Parameters:
      ctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs to
      in - the ByteBuf from which to read data
      out - the List to which decoded messages should be added
      Throws:
      Exception - is thrown if an error occurs
    • invalidMessage

      private M invalidMessage(Exception cause)
      Helper method to create a message indicating a invalid decoding result.
      Parameters:
      cause - the cause of the decoding failure.
      Returns:
      a valid message indicating failure.
    • invalidChunk

      private MemcacheContent invalidChunk(Exception cause)
      Helper method to create a content chunk indicating a invalid decoding result.
      Parameters:
      cause - the cause of the decoding failure.
      Returns:
      a valid content chunk indicating failure.
    • channelInactive

      public void channelInactive(ChannelHandlerContext ctx) throws Exception
      When the channel goes inactive, release all frames to prevent data leaks.
      Specified by:
      channelInactive in interface ChannelInboundHandler
      Overrides:
      channelInactive in class ByteToMessageDecoder
      Parameters:
      ctx - handler context
      Throws:
      Exception
    • resetDecoder

      protected void resetDecoder()
      Prepare for next decoding iteration.
    • decodeHeader

      protected abstract M decodeHeader(ByteBuf in)
      Decode and return the parsed BinaryMemcacheMessage.
      Parameters:
      in - the incoming buffer.
      Returns:
      the decoded header.
    • buildInvalidMessage

      protected abstract M buildInvalidMessage()
      Helper method to create a upstream message when the incoming parsing did fail.
      Returns:
      a message indicating a decoding failure.