public class CommandHandler
extends io.netty.channel.ChannelDuplexHandler
ChannelHandler responsible for writing redis commands and reading responses from the server.| Modifier and Type | Class and Description |
|---|---|
static class |
CommandHandler.LifecycleState |
| 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(io.netty.channel.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(io.netty.buffer.ByteBuf buffer)
Decoding hook: Can the buffer be decoded to a command.
|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelRegistered(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelUnregistered(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
complete(RedisCommand<?,?,?> command)
Decoding hook: Complete a command.
|
protected boolean |
decode(io.netty.buffer.ByteBuf buffer,
CommandOutput<?,?,?> output) |
protected boolean |
decode(io.netty.buffer.ByteBuf buffer,
RedisCommand<?,?,?> command,
CommandOutput<?,?,?> output) |
protected void |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf buffer) |
Collection<RedisCommand<?,?,?>> |
drainQueue() |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
String |
getChannelId() |
protected CommandOutput<?,?,?> |
getCommandOutput(RedisCommand<?,?,?> command)
Decoding hook: Retrieve
CommandOutput for RedisCommand decoding. |
Endpoint |
getEndpoint() |
Queue<RedisCommand<?,?,?>> |
getStack() |
protected CommandHandler.LifecycleState |
getState() |
boolean |
isClosed() |
protected boolean |
isPushDecode(io.netty.buffer.ByteBuf buffer) |
protected void |
notifyPushListeners(PushMessage notification) |
protected void |
setState(CommandHandler.LifecycleState lifecycleState) |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, readchannelReadComplete, channelWritabilityChangedensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic 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 Endpoint getEndpoint()
public Queue<RedisCommand<?,?,?>> getStack()
protected void setState(CommandHandler.LifecycleState lifecycleState)
public Collection<RedisCommand<?,?,?>> drainQueue()
protected CommandHandler.LifecycleState getState()
public boolean isClosed()
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelRegistered in interface io.netty.channel.ChannelInboundHandlerchannelRegistered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelRegistered(io.netty.channel.ChannelHandlerContext)public void channelUnregistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelUnregistered in interface io.netty.channel.ChannelInboundHandlerchannelUnregistered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelUnregistered(io.netty.channel.ChannelHandlerContext)public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered in interface io.netty.channel.ChannelInboundHandleruserEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.userEventTriggered(io.netty.channel.ChannelHandlerContext, Object)public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelActive(io.netty.channel.ChannelHandlerContext)public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelInactive(io.netty.channel.ChannelHandlerContext)public void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionChannelDuplexHandler.write(io.netty.channel.ChannelHandlerContext, java.lang.Object,
io.netty.channel.ChannelPromise)public void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelRead(io.netty.channel.ChannelHandlerContext, java.lang.Object)protected void decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf buffer)
throws InterruptedException
InterruptedExceptionprotected void notifyPushListeners(PushMessage notification)
protected boolean canDecode(io.netty.buffer.ByteBuf buffer)
buffer - protected boolean isPushDecode(io.netty.buffer.ByteBuf 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(io.netty.buffer.ByteBuf buffer,
CommandOutput<?,?,?> output)
protected boolean decode(io.netty.buffer.ByteBuf buffer,
RedisCommand<?,?,?> command,
CommandOutput<?,?,?> output)
protected void afterDecode(io.netty.channel.ChannelHandlerContext ctx,
RedisCommand<?,?,?> command)
ctx - command - public String getChannelId()
Copyright © 2024 lettuce.io. All rights reserved.