Class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMessage>

    • Constructor Detail

      • AbstractBinaryMemcacheDecoder

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

      • validateHeader

        private static void validateHeader​(BinaryMemcacheMessage header)
        Validates the length fields of a decoded header against each other.

        A header that fails this check can not be framed, so decoding stops permanently rather than attempting to resynchronize, see the class documentation.

        Note that keyLength and extrasLength are unsigned in the protocol and are interpreted as such here, see BinaryMemcacheMessage.keyLength() and BinaryMemcacheMessage.extrasLength().

        Parameters:
        header - the decoded header to validate.
        Throws:
        CorruptedFrameException - if the lengths in the header are inconsistent.
      • invalidMessage

        private M invalidMessage​(java.lang.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​(java.lang.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.
      • 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.