K - Key type.V - Value type.@ChannelHandler.Sharable public class CommandHandler<K,V> extends ChannelDuplexHandler implements RedisChannelWriter<K,V>
ChannelHandler responsible for writing redis commands and reading responses from the server.ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
protected ByteBuf |
buffer |
protected ClientOptions |
clientOptions |
protected BlockingQueue<RedisCommand<K,V,?>> |
commandBuffer |
protected BlockingQueue<RedisCommand<K,V,?>> |
queue |
protected RedisStateMachine<K,V> |
rsm |
| Constructor and Description |
|---|
CommandHandler(ClientOptions clientOptions,
BlockingQueue<RedisCommand<K,V,?>> queue)
Initialize a new instance that handles commands from the supplied queue.
|
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(ChannelHandlerContext ctx) |
void |
channelInactive(ChannelHandlerContext ctx) |
void |
channelRead(ChannelHandlerContext ctx,
Object msg) |
void |
channelRegistered(ChannelHandlerContext ctx) |
void |
channelUnregistered(ChannelHandlerContext ctx) |
void |
close()
Close the connection.
|
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf buffer) |
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) |
protected void |
executeQueuedCommands(ChannelHandlerContext ctx) |
boolean |
isClosed() |
void |
reset()
Reset the writer state.
|
void |
setRedisChannelHandler(RedisChannelHandler<K,V> redisChannelHandler)
Set the corresponding connection instance in order to notify it about channel active/inactive state.
|
void |
write(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise) |
<T> RedisCommand<K,V,T> |
write(RedisCommand<K,V,T> command)
Write a command on the channel.
|
bind, close, connect, deregister, disconnect, flush, readchannelReadComplete, channelWritabilityChanged, userEventTriggeredhandlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedprotected ClientOptions clientOptions
protected BlockingQueue<RedisCommand<K,V,?>> queue
protected BlockingQueue<RedisCommand<K,V,?>> commandBuffer
protected ByteBuf buffer
protected RedisStateMachine<K,V> rsm
public CommandHandler(ClientOptions clientOptions, BlockingQueue<RedisCommand<K,V,?>> queue)
clientOptions - queue - The command queue.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 ChannelInboundHandlerAdapterExceptionpublic 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
InterruptedExceptionpublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught in interface ChannelHandlerexceptionCaught in interface ChannelInboundHandlerexceptionCaught in class ChannelInboundHandlerAdapterExceptionpublic <T> RedisCommand<K,V,T> write(RedisCommand<K,V,T> command)
RedisChannelWriterwrite in interface RedisChannelWriter<K,V>T - result typecommand - the redis commandpublic void channelActive(ChannelHandlerContext ctx) throws Exception
channelActive in interface ChannelInboundHandlerchannelActive in class ChannelInboundHandlerAdapterExceptionprotected void executeQueuedCommands(ChannelHandlerContext ctx)
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 channelInactive(ChannelHandlerContext ctx) throws Exception
channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionChannelInboundHandlerAdapter.channelInactive(io.netty.channel.ChannelHandlerContext)public void close()
close in interface RedisChannelWriter<K,V>close in interface Closeableclose in interface AutoCloseablepublic boolean isClosed()
public void setRedisChannelHandler(RedisChannelHandler<K,V> redisChannelHandler)
RedisChannelWritersetRedisChannelHandler in interface RedisChannelWriter<K,V>redisChannelHandler - the channel handler (external connection object)public void reset()
reset in interface RedisChannelWriter<K,V>Copyright © 2015. All rights reserved.