@Override protected NettyTcpChannel bind(String name, InetSocketAddress address) { Channel channel = serverBootstraps.get(name).bind(address).syncUninterruptibly().channel(); NettyTcpChannel esChannel = new NettyTcpChannel(channel); channel.attr(CHANNEL_KEY).set(esChannel); return esChannel; }
@Override public String toString() { return "NettyTcpChannel{" + "localAddress=" + getLocalAddress() + ", remoteAddress=" + channel.remoteAddress() + '}'; } }
final SslHandler sslhandler = (SslHandler) nettyChannel.getLowLevelChannel().pipeline().get("ssl_server");
@Override protected NettyTcpChannel bind(String name, InetSocketAddress address) { Channel channel = serverBootstraps.get(name).bind(address).syncUninterruptibly().channel(); NettyTcpChannel esChannel = new NettyTcpChannel(channel); channel.attr(CHANNEL_KEY).set(esChannel); return esChannel; }
@Override public String toString() { return "NettyTcpChannel{" + "localAddress=" + getLocalAddress() + ", remoteAddress=" + channel.remoteAddress() + '}'; } }
@Override protected void initChannel(Channel ch) throws Exception { addClosedExceptionLogger(ch); NettyTcpChannel nettyTcpChannel = new NettyTcpChannel(ch); ch.attr(CHANNEL_KEY).set(nettyTcpChannel); serverAcceptedChannel(nettyTcpChannel); ch.pipeline().addLast("logging", new ESLoggingHandler()); ch.pipeline().addLast("size", new Netty4SizeHeaderFrameDecoder()); ch.pipeline().addLast("dispatcher", new Netty4MessageChannelHandler(Netty4Transport.this, name)); }
@Override public String toString() { return "NettyTcpChannel{" + "localAddress=" + getLocalAddress() + ", remoteAddress=" + channel.remoteAddress() + '}'; } }
@Override protected void initChannel(Channel ch) throws Exception { addClosedExceptionLogger(ch); NettyTcpChannel nettyTcpChannel = new NettyTcpChannel(ch); ch.attr(CHANNEL_KEY).set(nettyTcpChannel); serverAcceptedChannel(nettyTcpChannel); ch.pipeline().addLast("logging", new ESLoggingHandler()); ch.pipeline().addLast("size", new Netty4SizeHeaderFrameDecoder()); ch.pipeline().addLast("dispatcher", new Netty4MessageChannelHandler(Netty4Transport.this, name)); }
@Override protected void initChannel(Channel ch) throws Exception { addClosedExceptionLogger(ch); NettyTcpChannel nettyTcpChannel = new NettyTcpChannel(ch); ch.attr(CHANNEL_KEY).set(nettyTcpChannel); serverAcceptedChannel(nettyTcpChannel); ch.pipeline().addLast("logging", new ESLoggingHandler()); ch.pipeline().addLast("size", new Netty4SizeHeaderFrameDecoder()); ch.pipeline().addLast("dispatcher", new Netty4MessageChannelHandler(Netty4Transport.this, name)); }
@Override protected NettyTcpChannel initiateChannel(DiscoveryNode node, TimeValue connectTimeout, ActionListener<Void> listener) throws IOException { ChannelFuture channelFuture = bootstrap.connect(node.getAddress().address()); Channel channel = channelFuture.channel(); if (channel == null) { Netty4Utils.maybeDie(channelFuture.cause()); throw new IOException(channelFuture.cause()); } addClosedExceptionLogger(channel); NettyTcpChannel nettyChannel = new NettyTcpChannel(channel); channel.attr(CHANNEL_KEY).set(nettyChannel); channelFuture.addListener(f -> { if (f.isSuccess()) { listener.onResponse(null); } else { Throwable cause = f.cause(); if (cause instanceof Error) { Netty4Utils.maybeDie(cause); listener.onFailure(new Exception(cause)); } else { listener.onFailure((Exception) cause); } } }); return nettyChannel; }
@Override protected NettyTcpChannel initiateChannel(DiscoveryNode node, ActionListener<Void> listener) throws IOException { InetSocketAddress address = node.getAddress().address(); Bootstrap bootstrapWithHandler = clientBootstrap.clone(); bootstrapWithHandler.handler(getClientChannelInitializer(node)); bootstrapWithHandler.remoteAddress(address); ChannelFuture channelFuture = bootstrapWithHandler.connect(); Channel channel = channelFuture.channel(); if (channel == null) { ExceptionsHelper.maybeDieOnAnotherThread(channelFuture.cause()); throw new IOException(channelFuture.cause()); } addClosedExceptionLogger(channel); NettyTcpChannel nettyChannel = new NettyTcpChannel(channel); channel.attr(CHANNEL_KEY).set(nettyChannel); channelFuture.addListener(f -> { if (f.isSuccess()) { listener.onResponse(null); } else { Throwable cause = f.cause(); if (cause instanceof Error) { ExceptionsHelper.maybeDieOnAnotherThread(cause); listener.onFailure(new Exception(cause)); } else { listener.onFailure((Exception) cause); } } }); return nettyChannel; }