future = channel.connect(remoteAddress).awaitUninterruptibly(); if (!future.isSuccess()) { tries++;
return ch.connect(remoteAddress);
return ch.connect(remoteAddress);
channel.connect(server.address).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception {
private <K, V, T extends RedisAsyncConnection<K, V>> T connect(CommandHandler<K, V> handler, T connection) { try { ConnectionWatchdog watchdog = new ConnectionWatchdog(bootstrap, channels, timer); ChannelPipeline pipeline = Channels.pipeline(watchdog, handler, connection); Channel channel = bootstrap.getFactory().newChannel(pipeline); ChannelFuture future = channel.connect((SocketAddress) bootstrap.getOption("remoteAddress")); future.await(); if (!future.isSuccess()) { throw future.getCause(); } watchdog.setReconnect(true); return connection; } catch (Throwable e) { throw new RedisException("Unable to connect", e); } }
private <K, V, T extends RedisAsyncConnection<K, V>> T connect(CommandHandler<K, V> handler, T connection) { try { ConnectionWatchdog watchdog = new ConnectionWatchdog(bootstrap, channels, timer); ChannelPipeline pipeline = Channels.pipeline(watchdog, handler, connection); Channel channel = bootstrap.getFactory().newChannel(pipeline); ChannelFuture future = channel.connect((SocketAddress) bootstrap.getOption("remoteAddress")); future.await(); if (!future.isSuccess()) { throw future.getCause(); } watchdog.setReconnect(true); return connection; } catch (Throwable e) { throw new RedisException("Unable to connect", e); } }
/** * Reconnect to the remote address that the closed channel was connected to. * This creates a new {@link ChannelPipeline} with the same handler instances * contained in the old channel's pipeline. * * @param timeout Timer task handle. * * @throws Exception when reconnection fails. */ @Override public void run(Timeout timeout) throws Exception { ChannelPipeline old = channel.getPipeline(); CommandHandler<?, ?> handler = old.get(CommandHandler.class); RedisAsyncConnection<?, ?> connection = old.get(RedisAsyncConnection.class); ChannelPipeline pipeline = Channels.pipeline(this, handler, connection); Channel c = bootstrap.getFactory().newChannel(pipeline); c.getConfig().setOptions(bootstrap.getOptions()); c.connect((SocketAddress) bootstrap.getOption("remoteAddress")); } }
/** * Reconnect to the remote address that the closed channel was connected to. * This creates a new {@link ChannelPipeline} with the same handler instances * contained in the old channel's pipeline. * * @param timeout Timer task handle. * * @throws Exception when reconnection fails. */ @Override public void run(Timeout timeout) throws Exception { ChannelPipeline old = channel.getPipeline(); CommandHandler<?, ?> handler = old.get(CommandHandler.class); RedisAsyncConnection<?, ?> connection = old.get(RedisAsyncConnection.class); ChannelPipeline pipeline = Channels.pipeline(this, handler, connection); Channel c = bootstrap.getFactory().newChannel(pipeline); c.getConfig().setOptions(bootstrap.getOptions()); c.connect((SocketAddress) bootstrap.getOption("remoteAddress")); } }
channel.connect(remote);
return ch.connect(remoteAddress);