Package org.infinispan.server.resp
Class RespRequestHandler
java.lang.Object
org.infinispan.server.resp.RespRequestHandler
- Direct Known Subclasses:
CacheRespRequestHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.netty.util.AttributeKey<ByteBufPool> protected final CompletionStage<RespRequestHandler> protected final RespServer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.Acquire the buffer allocator in the current context.voidhandleChannelDisconnect(io.netty.channel.ChannelHandlerContext ctx) handleRequest(io.netty.channel.ChannelHandlerContext ctx, RespCommand command, List<byte[]> arguments) protected voidinitializeIfNecessary(io.netty.channel.ChannelHandlerContext ctx) myStage()stageToReturn(CompletionStage<E> stage, io.netty.channel.ChannelHandlerContext ctx, BiConsumer<? super E, ByteBufPool> biConsumer) stageToReturn(CompletionStage<E> stage, io.netty.channel.ChannelHandlerContext ctx, Function<E, RespRequestHandler> handlerWhenComplete) stageToReturn(CompletionStage<RespRequestHandler> stage, io.netty.channel.ChannelHandlerContext ctx)
-
Field Details
-
myStage
-
respServer
-
BYTE_BUF_POOL_ATTRIBUTE_KEY
-
-
Constructor Details
-
RespRequestHandler
-
-
Method Details
-
initializeIfNecessary
protected void initializeIfNecessary(io.netty.channel.ChannelHandlerContext ctx) -
respServer
-
myStage
-
allocator
Acquire the buffer allocator in the current context.The
Thread-safety: The allocator and theByteBufPoolprovides the means to allocate aByteBufwith the required free size. All the writes must utilize theByteBufPoolinstead of manually allocating buffers.ByteBufmust be utilized only from the event loop thread. Use theChannelHandlerContextto verify.- Returns:
- A
ByteBufallocator.
-
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
allocatorToUseto 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 requesttype- The command typearguments- 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)
-