设为首页 加入收藏

TOP

RocketMQ4.3.X关于设置useEpollNativeSelector = true报错问题(一)
2019-09-17 16:59:21 】 浏览:45
Tags:RocketMQ4.3.X 关于 设置 useEpollNativeSelector true 问题

前一阵子刚整理完RocketMQ4.3.x版本的相关配置的工作,接下来就来测试一下改变参数会带来什么好的结果

首先我就选中了useEpollNativeSelector 这个参数

默认这个参数是 false

这个参数的意思就是是否启用Epoll IO模型。Linux环境建议开启


然后我就打开了这个参数试试看看会不会生效

首先是namesrv 弄了一个配置文件指向启动

然后启动namesrv

sh bin/mqnamesrv -c conf/namesrv.conf 

很不幸抛出了一个异常

java.lang.IllegalStateException: incompatible event loop type: io.netty.channel.nio.NioEventLoop
	at io.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:411)
	at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:72)
	at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:60)
	at io.netty.channel.MultithreadEventLoopGroup.register(MultithreadEventLoopGroup.java:64)
	at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:320)
	at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:271)
	at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:235)
	at org.apache.rocketmq.remoting.netty.NettyRemotingServer.start(NettyRemotingServer.java:212)
	at org.apache.rocketmq.namesrv.NamesrvController.start(NamesrvController.java:156)
	at org.apache.rocketmq.namesrv.NamesrvStartup.start(NamesrvStartup.java:154)
	at org.apache.rocketmq.namesrv.NamesrvStartup.main0(NamesrvStartup.java:58)
	at org.apache.rocketmq.namesrv.NamesrvStartup.main(NamesrvStartup.java:51)

 

通过抛出的异常追查一下源码

源码位置

发现在执行构造函数的时候初始化的是下面代码 90-143行

public NettyRemotingServer(final NettyServerConfig nettyServerConfig,
        final ChannelEventListener channelEventListener) {
        super(nettyServerConfig.getServerOnewaySemaphoreva lue(), nettyServerConfig.getServerAsyncSemaphoreva lue());
        this.serverBootstrap = new ServerBootstrap();
        this.nettyServerConfig = nettyServerConfig;
        this.channelEventListener = channelEventListener;

        int publicThreadNums = nettyServerConfig.getServerCallbackExecutorThreads();
        if (publicThreadNums <= 0) {
            publicThreadNums = 4;
        }

        this.publicExecutor = Executors.newFixedThreadPool(publicThreadNums, new ThreadFactory() {
            private AtomicInteger threadIndex = new AtomicInteger(0);

            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, "NettyServerPublicExecutor_" + this.threadIndex.incrementAndGet());
            }
        });

        this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() {
            private AtomicInteger threadIndex = new AtomicInteger(0);

            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, String.format("NettyBoss_%d", this.threadIndex.incrementAndGet()));
            }
        });

        if (useEpoll()) {
            this.eventLoopGroupSelector = new EpollEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
                private AtomicInteger threadIndex = new AtomicInteger(0);
                private int threadTotal = nettyServerConfig.getServerSelectorThreads();

                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r, String.format("NettyServerEPOLLSelector_%d_%d", threadTotal, this.threadIndex.incrementAndGet()));
                }
            });
        } else {
            this.eventLoopGroupSelector = new NioEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new Thread
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇AppBoxFuture(四). 随需而变-Onli.. 下一篇老王说架构

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目