@Override public void connect() throws Exception { ChannelFuture channelFuture = bootstrap.connect( destination.socketAddress() ); nettyChannel = channelFuture.sync().channel(); nettyChannel.closeFuture().addListener( (ChannelFutureListener) future -> handler.onClose() ); }
CatchUpChannel( AdvertisedSocketAddress destination ) { this.destination = destination; handler = new TrackingResponseHandler( new CatchUpResponseAdaptor(), clock ); Bootstrap bootstrap = new Bootstrap() .group( eventLoopGroup ) .channel( NioSocketChannel.class ) .handler( new ChannelInitializer<SocketChannel>() { @Override protected void initChannel( SocketChannel ch ) throws Exception { CatchUpClientChannelPipeline.initChannel( ch, handler, logProvider, monitors ); } } ); ChannelFuture channelFuture = bootstrap.connect( destination.socketAddress() ); nettyChannel = channelFuture.awaitUninterruptibly().channel(); }
private NonBlockingChannel channel( AdvertisedSocketAddress to ) { MessageQueueMonitor monitor = monitors.newMonitor( MessageQueueMonitor.class, NonBlockingChannel.class ); NonBlockingChannel nonBlockingChannel = nonBlockingChannels.get( to ); if ( nonBlockingChannel == null ) { nonBlockingChannel = new NonBlockingChannel( bootstrap, to.socketAddress(), log, monitor, maxQueueSize ) ; NonBlockingChannel existingNonBlockingChannel = nonBlockingChannels.putIfAbsent( to, nonBlockingChannel ); if ( existingNonBlockingChannel != null ) { nonBlockingChannel.dispose(); nonBlockingChannel = existingNonBlockingChannel; } } monitor.register( to.socketAddress() ); return nonBlockingChannel; }