Channel ch = getFactory().newChannel(pipeline); boolean success = false; try {
Channel ch = getFactory().newChannel(pipeline); boolean success = false; try {
@Override public ChannelFuture connect() throws URISyntaxException { this.sessionId = UUID.randomUUID().toString(); URI sockJsUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + "/999/" + sessionId + "/websocket", uri.getQuery(), uri.getFragment()); this.wsHandshaker = new WebSocketClientHandshakerFactory().newHandshaker( sockJsUri, WebSocketVersion.V13, null, false, null); if (bootstrap.getFactory() instanceof LocalClientChannelFactory) { return bootstrap.connect(new LocalAddress(getPort(uri))); } else { return bootstrap.connect(new InetSocketAddress(uri.getHost(), getPort(uri))); } }
public static void connect(final ClientOptions options) { final ClientBootstrap bootstrap = getBootstrap(Executors.newCachedThreadPool(), options); final ChannelFuture future = bootstrap.connect(new InetSocketAddress(options.getHost(), options.getPort())); future.awaitUninterruptibly(); if(!future.isSuccess()) { // future.getCause().printStackTrace(); logger.error("error creating client connection: {}", future.getCause().getMessage()); } future.getChannel().getCloseFuture().awaitUninterruptibly(); bootstrap.getFactory().releaseExternalResources(); }
public static void connect(final ClientOptions options) { final ClientBootstrap bootstrap = getBootstrap(Executors.newCachedThreadPool(), options); final ChannelFuture future = bootstrap.connect(new InetSocketAddress(options.getHost(), options.getPort())); future.awaitUninterruptibly(); if(!future.isSuccess()) { // future.getCause().printStackTrace(); logger.error("error creating client connection: {}", future.getCause().getMessage()); } future.getChannel().getCloseFuture().awaitUninterruptibly(); bootstrap.getFactory().releaseExternalResources(); }
bootstrap.getFactory().releaseExternalResources();
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); } }
Channel ch = getFactory().newChannel(pipeline); boolean success = false; try {
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); } }
Channel ch = getFactory().newChannel(pipeline); boolean success = false; try {
final TimeValue defaultConnectTimeout = defaultConnectionProfile.getConnectTimeout(); if (profile.getConnectTimeout() != null && profile.getConnectTimeout().equals(defaultConnectTimeout) == false) { clientBootstrap = new ClientBootstrap(this.clientBootstrap.getFactory()); clientBootstrap.setPipelineFactory(this.clientBootstrap.getPipelineFactory()); clientBootstrap.setOptions(this.clientBootstrap.getOptions());
/** * 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")); } }