use of org.apache.ratis.thirdparty.io.netty.bootstrap.Bootstrap in project incubator-ratis by apache.
the class NettyClient method connect.
/**
* Connects to the given server address.
*/
public void connect(String serverAddress, EventLoopGroup group, ChannelInitializer<SocketChannel> initializer) throws InterruptedException {
final InetSocketAddress address = NetUtils.createSocketAddr(serverAddress);
lifeCycle.startAndTransition(() -> channel = new Bootstrap().group(group).channel(NioSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO)).handler(initializer).connect(address).sync().channel(), InterruptedException.class);
}
use of org.apache.ratis.thirdparty.io.netty.bootstrap.Bootstrap in project incubator-ratis by apache.
the class NettyClient method setupClient.
public void setupClient() throws Exception {
String host = "localhost";
int port = 50053;
channel = (new Bootstrap()).group(workerGroup).channel(NioSocketChannel.class).handler(getInitializer()).option(ChannelOption.SO_KEEPALIVE, true).connect(host, port).sync().channel();
}
Aggregations