Search in sources :

Example 1 with Bootstrap

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);
}
Also used : NioSocketChannel(org.apache.ratis.thirdparty.io.netty.channel.socket.nio.NioSocketChannel) LoggingHandler(org.apache.ratis.thirdparty.io.netty.handler.logging.LoggingHandler) InetSocketAddress(java.net.InetSocketAddress) Bootstrap(org.apache.ratis.thirdparty.io.netty.bootstrap.Bootstrap)

Example 2 with Bootstrap

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();
}
Also used : Bootstrap(org.apache.ratis.thirdparty.io.netty.bootstrap.Bootstrap)

Aggregations

Bootstrap (org.apache.ratis.thirdparty.io.netty.bootstrap.Bootstrap)2 InetSocketAddress (java.net.InetSocketAddress)1 NioSocketChannel (org.apache.ratis.thirdparty.io.netty.channel.socket.nio.NioSocketChannel)1 LoggingHandler (org.apache.ratis.thirdparty.io.netty.handler.logging.LoggingHandler)1