private CompletableFuture < Channel > bootstrapClient ( Address address ) { CompletableFuture < Channel > future = new OrderedFuture <> ( ) ; Bootstrap bootstrap = new Bootstrap ( ) ; bootstrap . option ( ChannelOption . ALLOCATOR , PooledByteBufAllocator . DEFAULT ) ; bootstrap . option ( ChannelOption . WRITE_BUFFER_WATER_MARK , new WriteBufferWaterMark ( 10 * 32 * 1024 , 10 * 64 * 1024 ) ) ; bootstrap . option ( ChannelOption . SO_RCVBUF , 1024 * 1024 ) ; bootstrap . option ( ChannelOption . SO_SNDBUF , 1024 * 1024 ) ; bootstrap . option ( ChannelOption . SO_KEEPALIVE , true ) ; bootstrap . option ( ChannelOption . TCP_NODELAY , true ) ; bootstrap . option ( ChannelOption . CONNECT_TIMEOUT_MILLIS , 1000 ) ; bootstrap . group ( clientGroup ) ; // TODO: Make this faster: // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 bootstrap . channel ( clientChannelClass ) ; bootstrap . remoteAddress ( address . address ( true ) , address . port ( ) ) ; if ( enableNettyTls ) { try { bootstrap . handler ( new SslClientChannelInitializer ( future , address ) ) ; } catch ( SSLException e ) { return Futures . exceptionalFuture ( e ) ; } } else { bootstrap . handler ( new BasicClientChannelInitializer ( future ) ) ; } bootstrap . connect ( ) . addListener ( f -> { if ( ! f . isSuccess ( ) ) { future . completeExceptionally ( f . cause ( ) ) ; } } ) ; return future ; }
Bootstraps a new channel to the given address .