Search in sources :

Example 1 with ServerBootstrap

use of com.couchbase.client.core.deps.io.netty.bootstrap.ServerBootstrap in project couchbase-jvm-clients by couchbase.

the class BaseEndpointIntegrationTest method startLocalServer.

private LocalServerController startLocalServer(final DefaultEventLoopGroup eventLoopGroup) {
    final LocalServerController localServerController = new LocalServerController();
    ServerBootstrap bootstrap = new ServerBootstrap().group(eventLoopGroup).localAddress(new LocalAddress("server")).childHandler(new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel ch) {
            ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {

                @Override
                protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
                }

                @Override
                public void channelActive(ChannelHandlerContext ctx) {
                    localServerController.channel.set(ctx.channel());
                    localServerController.connectAttempts.incrementAndGet();
                    ctx.fireChannelActive();
                }
            });
        }
    }).channel(LocalServerChannel.class);
    bootstrap.bind().awaitUninterruptibly();
    return localServerController;
}
Also used : LocalAddress(com.couchbase.client.core.deps.io.netty.channel.local.LocalAddress) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) LocalServerChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalServerChannel) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) ChannelInitializer(com.couchbase.client.core.deps.io.netty.channel.ChannelInitializer) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) ServerBootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.ServerBootstrap)

Aggregations

ServerBootstrap (com.couchbase.client.core.deps.io.netty.bootstrap.ServerBootstrap)1 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)1 Channel (com.couchbase.client.core.deps.io.netty.channel.Channel)1 ChannelHandlerContext (com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext)1 ChannelInitializer (com.couchbase.client.core.deps.io.netty.channel.ChannelInitializer)1 LocalAddress (com.couchbase.client.core.deps.io.netty.channel.local.LocalAddress)1 LocalServerChannel (com.couchbase.client.core.deps.io.netty.channel.local.LocalServerChannel)1