public class CommandHandler extends ChannelDuplexHandler
ChannelHandler responsible for writing redis commands and reading responses from the server.| Modifier and Type | Class and Description |
|---|---|
static class |
CommandHandler.LifecycleState |
ChannelHandler.Sharable| Constructor and Description |
|---|
CommandHandler(ClientOptions clientOptions,
ClientResources clientResources,
Endpoint endpoint)
Initialize a new instance that handles commands from the supplied queue.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterDecode(ChannelHandlerContext ctx,
RedisCommand<?,?,?> command)
Hook method called after command completion.
|
protected boolean |
canComplete(RedisCommand<?,?,?> command)
Decoding hook: Can the command be completed.
|
protected boolean |
canDecode(ByteBuf buffer)
Decoding hook: Can the buffer be decoded to a command.
|
void |
channelActive(ChannelHandlerContext ctx) |
void |
channelInactive(ChannelHandlerContext ctx) |
void |
channelRead(ChannelHandlerContext ctx,
Object msg) |
void |
channelRegistered(ChannelHandlerContext ctx) |
void |
channelUnregistered(ChannelHandlerContext ctx) |
protected void |
complete(RedisCommand<?,?,?> command)
Decoding hook: Complete a command.
|
protected boolean |
decode(ByteBuf buffer,
CommandOutput<?,?,?> output) |
protected boolean |
decode(ByteBuf buffer,
RedisCommand<?,?,?> command,
CommandOutput<?,?,?> output) |
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf buffer) |
Collection<RedisCommand<?,?,?>> |
drainQueue() |
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) |
protected CommandOutput<?,?,?> |
getCommandOutput(RedisCommand<?,?,?> command)
Decoding hook: Retrieve
CommandOutput for RedisCommand decoding. |
Queue<RedisCommand<?,?,?>> |
getStack() |
protected CommandHandler.LifecycleState |
getState() |
boolean |
isClosed() |
protected void |
setState(CommandHandler.LifecycleState lifecycleState) |
void |
userEventTriggered(ChannelHandlerContext ctx,
Object evt) |
void |
write(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, readchannelReadComplete, channelWritabilityChangedensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedpublic CommandHandler(ClientOptions clientOptions, ClientResources clientResources, Endpoint endpoint)
clientOptions - client options for this connection, must not be nullclientResources - client resources for this connection, must not be nullendpoint - must not be null.public Queue<RedisCommand<?,?,?>> getStack()
protected void setState(CommandHandler.LifecycleState lifecycleState)
public Collection<RedisCommand<?,?,?>> drainQueue()
protected CommandHandler.LifecycleState getState()
public boolean isClosed()
public void channelRegistered(ChannelHandlerContext ctx) throws Exception
channelRegistered in interface ChannelInboundHandlerchannelRegistered in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelRegistered(io.netty.channel.ChannelHandlerContext)public void channelUnregistered(ChannelHandlerContext ctx) throws Exception
channelUnregistered in interface ChannelInboundHandlerchannelUnregistered in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelUnregistered(io.netty.channel.ChannelHandlerContext)public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
userEventTriggered in interface ChannelInboundHandleruserEventTriggered in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.userEventTriggered(io.netty.channel.ChannelHandlerContext, Object)public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught in interface ChannelHandlerexceptionCaught in interface ChannelInboundHandlerexceptionCaught in class ChannelInboundHandlerAdapterExceptionpublic void channelActive(ChannelHandlerContext ctx) throws Exception
channelActive in interface ChannelInboundHandlerchannelActive in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelActive(io.netty.channel.ChannelHandlerContext)public void channelInactive(ChannelHandlerContext ctx) throws Exception
channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelInactive(io.netty.channel.ChannelHandlerContext)public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
write in interface ChannelOutboundHandlerwrite in class ChannelDuplexHandlerExceptionChannelDuplexHandler.write(io.netty.channel.ChannelHandlerContext, java.lang.Object,
io.netty.channel.ChannelPromise)public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
channelRead in interface ChannelInboundHandlerchannelRead in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelRead(io.netty.channel.ChannelHandlerContext, java.lang.Object)protected void decode(ChannelHandlerContext ctx, ByteBuf buffer) throws InterruptedException
InterruptedExceptionprotected boolean canDecode(ByteBuf buffer)
buffer - protected boolean canComplete(RedisCommand<?,?,?> command)
command - protected void complete(RedisCommand<?,?,?> command)
command - RedisCommand.complete()protected CommandOutput<?,?,?> getCommandOutput(RedisCommand<?,?,?> command)
CommandOutput for RedisCommand decoding.command - RedisCommand.getOutput()protected boolean decode(ByteBuf buffer, CommandOutput<?,?,?> output)
protected boolean decode(ByteBuf buffer, RedisCommand<?,?,?> command, CommandOutput<?,?,?> output)
protected void afterDecode(ChannelHandlerContext ctx, RedisCommand<?,?,?> command)
ctx - command - Copyright © 2019 lettuce.io. All rights reserved.