Class RequestLimitDecoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
org.infinispan.server.core.transport.RequestLimitDecoder
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
Direct Known Subclasses:
BaseRespDecoder, HotRodDecoder, MemcachedBaseDecoder

public abstract class RequestLimitDecoder extends io.netty.handler.codec.ByteToMessageDecoder
Base for the generated protocol decoders, tracking how many bytes the request being parsed has consumed so that a maximum content length can be enforced against it.

The count cannot be taken from the reader index alone. A request may be spread over any number of decode invocations, and the cumulation buffer can be compacted or replaced in between, so the progress each invocation makes is folded into a counter instead. startRequest(ByteBuf), which the grammars invoke at the start of every request, clears that counter, so the bytes of a preceding pipelined request are never charged against the request that follows it.

Since:
16.3
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder

    io.netty.handler.codec.ByteToMessageDecoder.Cumulator

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     

    Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

    COMPOSITE_CUMULATOR, MERGE_CUMULATOR
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    RequestLimitDecoder(int maxContentLength, int unlimited)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    bytesAvailable(io.netty.buffer.ByteBuf buf)
     
    protected void
    callDecode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out)
     
    int
    Number of bytes consumed so far by the request currently being parsed, for reporting only.
    final int
     
    protected void
    startRequest(io.netty.buffer.ByteBuf buf)
    Invoked when the parser starts reading a new request, so that the bytes of the request preceding it in the pipeline are not charged against it.

    Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

    actualReadableBytes, channelInactive, channelRead, channelReadComplete, decode, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, isSharable

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded
  • Field Details

    • maxContentLength

      protected final int maxContentLength
  • Constructor Details

    • RequestLimitDecoder

      protected RequestLimitDecoder(int maxContentLength, int unlimited)
  • Method Details

    • maxContentLength

      public final int maxContentLength()
    • callDecode

      protected void callDecode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out)
      Overrides:
      callDecode in class io.netty.handler.codec.ByteToMessageDecoder
    • startRequest

      protected void startRequest(io.netty.buffer.ByteBuf buf)
      Invoked when the parser starts reading a new request, so that the bytes of the request preceding it in the pipeline are not charged against it.
    • bytesAvailable

      protected int bytesAvailable(io.netty.buffer.ByteBuf buf)
    • currentRequestBytes

      public int currentRequestBytes()
      Number of bytes consumed so far by the request currently being parsed, for reporting only. Prefer bytesAvailable(ByteBuf): this is here for the generated header and error handling methods, which have no buffer parameter. With no buffer being decoded it reports the count as of the last decode invocation.