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


Java ServerBootstrap.validate方法代码示例

本文整理汇总了Java中io.netty.bootstrap.ServerBootstrap.validate方法的典型用法代码示例。如果您正苦于以下问题:Java ServerBootstrap.validate方法的具体用法?Java ServerBootstrap.validate怎么用?Java ServerBootstrap.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.bootstrap.ServerBootstrap的用法示例。


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

示例1: createServerBootstrap

import io.netty.bootstrap.ServerBootstrap; //导入方法依赖的package包/类
private void createServerBootstrap(String name, Settings settings) {
    if (logger.isDebugEnabled()) {
        logger.debug("using profile[{}], worker_count[{}], port[{}], bind_host[{}], publish_host[{}], compress[{}], "
                + "connect_timeout[{}], connections_per_node[{}/{}/{}/{}/{}], receive_predictor[{}->{}]",
            name, workerCount, settings.get("port"), settings.get("bind_host"), settings.get("publish_host"), compress,
            defaultConnectionProfile.getConnectTimeout(),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.RECOVERY),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.BULK),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.REG),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.STATE),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.PING),
            receivePredictorMin, receivePredictorMax);
    }

    final ThreadFactory workerFactory = daemonThreadFactory(this.settings, TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX, name);

    final ServerBootstrap serverBootstrap = new ServerBootstrap();

    serverBootstrap.group(new NioEventLoopGroup(workerCount, workerFactory));
    serverBootstrap.channel(NioServerSocketChannel.class);

    serverBootstrap.childHandler(getServerChannelInitializer(name, settings));

    serverBootstrap.childOption(ChannelOption.TCP_NODELAY, TCP_NO_DELAY.get(settings));
    serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, TCP_KEEP_ALIVE.get(settings));

    final ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.getDefault(settings);
    if (tcpSendBufferSize != null && tcpSendBufferSize.getBytes() > 0) {
        serverBootstrap.childOption(ChannelOption.SO_SNDBUF, Math.toIntExact(tcpSendBufferSize.getBytes()));
    }

    final ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.getDefault(settings);
    if (tcpReceiveBufferSize != null && tcpReceiveBufferSize.getBytes() > 0) {
        serverBootstrap.childOption(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.bytesAsInt()));
    }

    serverBootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
    serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);

    final boolean reuseAddress = TCP_REUSE_ADDRESS.get(settings);
    serverBootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
    serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, reuseAddress);

    serverBootstrap.validate();

    serverBootstraps.put(name, serverBootstrap);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:48,代码来源:Netty4Transport.java


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