/** Connect to a remote server asynchronously. * * @param bootstrap The channel boostrap to use * @return A {@link ChannelFuture} which is c */ private ChannelFuture connectAsync(@Nonnull Bootstrap bootstrap) { // If shutdown, return a ChannelFuture that is exceptionally completed. if (shutdown) { return new DefaultChannelPromise(channel, GlobalEventExecutor.INSTANCE) .setFailure(new ShutdownException("Runtime already shutdown!")); } // Use the bootstrap to create a new channel. ChannelFuture f = bootstrap.connect(node.getHost(), node.getPort()); f.addListener((ChannelFuture cf) -> channelConnectionFutureHandler(cf, bootstrap)); return f; }