@ChannelHandler.Sharable public class ConnectionWatchdog extends ChannelInboundHandlerAdapter implements TimerTask
ChannelHandler responsible for monitoring the channel and reconnecting when the connection is lost.ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
static long |
LOGGING_QUIET_TIME_MS |
| Constructor and Description |
|---|
ConnectionWatchdog(Delay reconnectDelay,
ClientOptions clientOptions,
Bootstrap bootstrap,
Timer timer,
EventExecutorGroup reconnectWorkers,
Supplier<SocketAddress> socketAddressSupplier,
ReconnectionListener reconnectionListener)
Create a new watchdog that adds to new connections to the supplied
ChannelGroup and establishes a new
Channel when disconnected, while reconnect is true. |
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(ChannelHandlerContext ctx) |
void |
channelInactive(ChannelHandlerContext ctx) |
boolean |
isListenOnChannelInactive() |
boolean |
isReconnectSuspended() |
void |
run(Timeout timeout)
Reconnect to the remote address that the closed channel was connected to.
|
void |
scheduleReconnect()
Schedule reconnect if channel is not available/not active.
|
void |
setListenOnChannelInactive(boolean listenOnChannelInactive) |
void |
setReconnectSuspended(boolean reconnectSuspended) |
void |
userEventTriggered(ChannelHandlerContext ctx,
Object evt) |
channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtensureNotSharable, handlerAdded, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAdded, handlerRemovedpublic ConnectionWatchdog(Delay reconnectDelay, ClientOptions clientOptions, Bootstrap bootstrap, Timer timer, EventExecutorGroup reconnectWorkers, Supplier<SocketAddress> socketAddressSupplier, ReconnectionListener reconnectionListener)
ChannelGroup and establishes a new
Channel when disconnected, while reconnect is true. The socketAddressSupplier can supply the reconnect address.reconnectDelay - reconnect delay, must not be nullclientOptions - client options for the current connection, must not be nullbootstrap - Configuration for new channels, must not be nulltimer - Timer used for delayed reconnect, must not be nullreconnectWorkers - executor group for reconnect tasks, must not be nullsocketAddressSupplier - the socket address supplier to obtain an address for reconnection, may be nullreconnectionListener - the reconnection listener, must not be nullpublic void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
userEventTriggered in interface ChannelInboundHandleruserEventTriggered in class ChannelInboundHandlerAdapterExceptionpublic void channelActive(ChannelHandlerContext ctx) throws Exception
channelActive in interface ChannelInboundHandlerchannelActive in class ChannelInboundHandlerAdapterExceptionpublic void channelInactive(ChannelHandlerContext ctx) throws Exception
channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionpublic void scheduleReconnect()
public void run(Timeout timeout) throws Exception
ChannelPipeline with
the same handler instances contained in the old channel's pipeline.public void setListenOnChannelInactive(boolean listenOnChannelInactive)
public boolean isListenOnChannelInactive()
public boolean isReconnectSuspended()
public void setReconnectSuspended(boolean reconnectSuspended)
Copyright © 2018 lettuce.io. All rights reserved.