/** Handle when a channel is connected. * * @param future The future that is completed when the channel is connected/ * @param bootstrap The bootstrap to connect a new channel (used on reconnect). */ private void channelConnectionFutureHandler(@Nonnull ChannelFuture future, @Nonnull Bootstrap bootstrap) { if (future.isSuccess()) { // Register a future to reconnect in case we get disconnected addReconnectionOnCloseFuture(future.channel(), bootstrap); log.info("connectAsync[{}]: Channel connected.", node); } else { // Otherwise, the connection failed. If we're not shutdown, try reconnecting after // a sleep period. if (!shutdown) { Sleep.sleepUninterruptibly(parameters.getConnectionRetryRate()); log.info("connectAsync[{}]: Channel connection failed, reconnecting...", node); // Call connect, which will retry the call again. // Note that this is not recursive, because it is called in the // context of the handler future. connectAsync(bootstrap); } } }