Example usage for io.netty.channel DefaultMessageSizeEstimator DefaultMessageSizeEstimator

List of usage examples for io.netty.channel DefaultMessageSizeEstimator DefaultMessageSizeEstimator

Introduction

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

Prototype

public DefaultMessageSizeEstimator(int unknownSize) 

Source Link

Document

Create a new instance

Usage

From source file:com.addthis.hydra.query.web.QueryServer.java

License:Apache License

public void run() throws Exception {
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    executorGroup = new DefaultEventExecutorGroup(AggregateConfig.FRAME_READER_THREADS,
            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("frame-reader-%d").build());
    for (EventExecutor executor : executorGroup) {
        executor.execute(new NextQueryTask(queryQueue, executor));
    }/*from  www .  j  av  a  2s . c o m*/
    ServerBootstrap b = new ServerBootstrap();
    b.option(ChannelOption.SO_BACKLOG, 1024);
    b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
    b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
    b.childOption(ChannelOption.MESSAGE_SIZE_ESTIMATOR, new DefaultMessageSizeEstimator(200));
    b.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 100000000);
    b.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 50000000);
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(queryServerInitializer);
    b.bind(webPort).sync();
}

From source file:com.baidu.jprotobuf.pbrpc.transport.RpcClient.java

License:Apache License

public RpcClient(Class<? extends Channel> clientChannelClass, RpcClientOptions rpcClientOptions) {
    this.workerGroup = new NioEventLoopGroup();
    this.group(workerGroup);
    this.channel(clientChannelClass);
    this.handler(new RpcClientPipelineinitializer(this));
    this.rpcClientOptions = rpcClientOptions;
    this.option(ChannelOption.SO_REUSEADDR, rpcClientOptions.isReuseAddress());
    this.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, rpcClientOptions.getConnectTimeout());
    this.option(ChannelOption.SO_SNDBUF, rpcClientOptions.getSendBufferSize());
    this.option(ChannelOption.SO_RCVBUF, rpcClientOptions.getSendBufferSize());
    this.option(ChannelOption.SO_KEEPALIVE, rpcClientOptions.isKeepAlive());
    this.option(ChannelOption.TCP_NODELAY, rpcClientOptions.getTcpNoDelay());
    this.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR,
            new DefaultMessageSizeEstimator(rpcClientOptions.getReceiveBufferSize()));

    // add count//from w w w . j a  v  a2s  . c  om
    INSTANCE_COUNT.incrementAndGet();
}