当前位置: 首页>>代码示例>>Java>>正文


Java AbstractChannelPoolHandler类代码示例

本文整理汇总了Java中io.netty.channel.pool.AbstractChannelPoolHandler的典型用法代码示例。如果您正苦于以下问题:Java AbstractChannelPoolHandler类的具体用法?Java AbstractChannelPoolHandler怎么用?Java AbstractChannelPoolHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractChannelPoolHandler类属于io.netty.channel.pool包,在下文中一共展示了AbstractChannelPoolHandler类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NettyHttpClient

import io.netty.channel.pool.AbstractChannelPoolHandler; //导入依赖的package包/类
public NettyHttpClient(ClientConfiguration configuration) {
    ThreadGroup threadGroup = new ThreadGroup("Netty RxS3 client");
    AtomicInteger threadCounter = new AtomicInteger();
    ThreadFactory threadFactory = r -> new Thread(threadGroup, r, "RxS3-client-worker" + threadCounter.getAndIncrement());
    group = new NioEventLoopGroup(configuration.getWorkerThreadCount(), threadFactory);

    String[] s3LocationArray = configuration.getS3Location().trim().split(":");

    s3Location = s3LocationArray[0];
    int port = 80;
    if (s3LocationArray.length == 2) {
        port = Integer.parseInt(s3LocationArray[1]);
    }

    demultiplexer = new HandlerDemultiplexer();

    Bootstrap bootstrap = new Bootstrap();
    bootstrap.group(group)
            .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
            .option(ChannelOption.SO_KEEPALIVE, true)
            .option(ChannelOption.TCP_NODELAY, true)
            .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, configuration.getConnectionTimeoutMillis())
            .channel(NioSocketChannel.class)
            .remoteAddress(s3Location, port);

    channelPool = new FixedChannelPool(bootstrap, new AbstractChannelPoolHandler() {

        HttpClientInitializer initializer = new HttpClientInitializer(demultiplexer);

        @Override
        public void channelCreated(Channel ch) {
            initializer.initChannel(ch);
        }
    }, ChannelHealthChecker.ACTIVE, FixedChannelPool.AcquireTimeoutAction.FAIL,
            configuration.getAcquireTimeoutMillis(), configuration.getMaxConnections(), configuration.getMaxPendingAcquires());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:37,代码来源:NettyHttpClient.java


注:本文中的io.netty.channel.pool.AbstractChannelPoolHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。