Class RespRequestHandler

java.lang.Object
org.infinispan.server.resp.RespRequestHandler
Direct Known Subclasses:
CacheRespRequestHandler

public abstract class RespRequestHandler extends Object
  • Field Details

  • Constructor Details

    • RespRequestHandler

      protected RespRequestHandler(RespServer server)
  • Method Details

    • initializeIfNecessary

      protected void initializeIfNecessary(io.netty.channel.ChannelHandlerContext ctx)
    • respServer

      public RespServer respServer()
    • myStage

    • allocator

      public ByteBufPool allocator()
      Acquire the buffer allocator in the current context.

      The ByteBufPool provides the means to allocate a ByteBuf with the required free size. All the writes must utilize the ByteBufPool instead of manually allocating buffers.

      Thread-safety: The allocator and the ByteBuf must be utilized only from the event loop thread. Use the ChannelHandlerContext to verify.
      Returns:
      A ByteBuf allocator.
    • handleRequest

      public final CompletionStage<RespRequestHandler> handleRequest(io.netty.channel.ChannelHandlerContext ctx, RespCommand command, List<byte[]> arguments)
    • actualHandleRequest

      protected CompletionStage<RespRequestHandler> actualHandleRequest(io.netty.channel.ChannelHandlerContext ctx, RespCommand type, List<byte[]> arguments)
      Handles the RESP request returning a stage that when complete notifies the command has completed as well as providing the request handler for subsequent commands.

      Implementations should never use the ByteBufAllocator in the context. Instead, they should use allocatorToUse to retrieve a ByteBuffer. This ByteBuffer should only have bytes written to it adding up to the size requested. The ByteBuffer itself should never be written to the context or channel and flush should also never be invoked. Failure to do so may cause mis-ordering or responses as requests support pipelining and a ByteBuf may not be send down stream until later in the pipeline.

      Parameters:
      ctx - Netty context pipeline for this request
      type - The command type
      arguments - The remaining arguments to the command
      Returns:
      stage that when complete returns the new handler to instate. This stage must be completed on the event loop
    • handleChannelDisconnect

      public void handleChannelDisconnect(io.netty.channel.ChannelHandlerContext ctx)
    • stageToReturn

      public <E> CompletionStage<RespRequestHandler> stageToReturn(CompletionStage<E> stage, io.netty.channel.ChannelHandlerContext ctx, BiConsumer<? super E,ByteBufPool> biConsumer)
    • stageToReturn

      public <E> CompletionStage<RespRequestHandler> stageToReturn(CompletionStage<E> stage, io.netty.channel.ChannelHandlerContext ctx, Function<E,RespRequestHandler> handlerWhenComplete)
    • stageToReturn

      public CompletionStage<RespRequestHandler> stageToReturn(CompletionStage<RespRequestHandler> stage, io.netty.channel.ChannelHandlerContext ctx)