Example usage for io.netty.channel MultithreadEventLoopGroup DEFAULT_EVENT_LOOP_THREADS

List of usage examples for io.netty.channel MultithreadEventLoopGroup DEFAULT_EVENT_LOOP_THREADS

Introduction

In this page you can find the example usage for io.netty.channel MultithreadEventLoopGroup DEFAULT_EVENT_LOOP_THREADS.

Prototype

int DEFAULT_EVENT_LOOP_THREADS

To view the source code for io.netty.channel MultithreadEventLoopGroup DEFAULT_EVENT_LOOP_THREADS.

Click Source Link

Usage

From source file:org.helios.octo.client.OctoShared.java

License:Open Source License

private OctoShared() {
    group = new NioEventLoopGroup(MultithreadEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS, this);
    channelGroup = new DefaultChannelGroup(group.next());
    bootstrap = new Bootstrap();
    bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
        @Override/*from ww  w . ja va 2s. c o  m*/
        public void initChannel(SocketChannel ch) throws Exception {
            ch.pipeline().addLast(LOGGING_HANDLER, loggingHandler);
            ch.pipeline().addLast(OBJECT_ENCODER, new ObjectEncoder());
            ch.pipeline().addLast(RESPONSE_HANDLER, responseHandler);
            //ch.pipeline().addLast(STREAM_DECODER, new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, Delimiters.lineDelimiter()));
            ch.pipeline().addLast(STRING_DECODER, new StringDecoder());
            ch.pipeline().addLast(STRING_PRINTER, stringPrinter);
            //ch.pipeline().addLast("decoder", new ObjectDecoder(ClassResolvers.cacheDisabled(null)));

        }
    });
    log.info("OctoShared Initialized");
}

From source file:org.ratpackframework.bootstrap.internal.NettyRatpackService.java

License:Apache License

@Override
protected void startUp() throws Exception {
    ServerBootstrap bootstrap = new ServerBootstrap();
    group = new NioEventLoopGroup(MultithreadEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS,
            new DefaultThreadFactory("ratpack-group", Thread.MAX_PRIORITY));

    bootstrap.group(group).channel(NioServerSocketChannel.class).childHandler(channelInitializer);

    bootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
    bootstrap.childOption(ChannelOption.TCP_NODELAY, true);
    bootstrap.option(ChannelOption.SO_REUSEADDR, true);
    bootstrap.option(ChannelOption.SO_BACKLOG, 1024);

    channel = bootstrap.bind(requestedAddress).sync().channel();
    boundAddress = (InetSocketAddress) channel.localAddress();

    if (logger.isLoggable(Level.INFO)) {
        logger.info(String.format("Ratpack started for http://%s:%s", getBindHost(), getBindPort()));
    }/*ww w .j  a  v a2s. c o  m*/
}