private static Pair<EventLoopGroup, Class<? extends Channel>> createEventLoopGroup( Configuration conf) { // Max amount of threads to use. 0 lets Netty decide based on amount of cores int maxThreads = conf.getInt(CLIENT_MAX_THREADS, 0); // Config to enable native transport. Does not seem to be stable at time of implementation // although it is not extensively tested. boolean epollEnabled = conf.getBoolean(USE_NATIVE_TRANSPORT, false); // Use the faster native epoll transport mechanism on linux if enabled if (epollEnabled && JVM.isLinux() && JVM.isAmd64()) { if (LOG.isDebugEnabled()) { LOG.debug("Create EpollEventLoopGroup with maxThreads = " + maxThreads); } return new Pair<EventLoopGroup, Class<? extends Channel>>(new EpollEventLoopGroup(maxThreads, Threads.newDaemonThreadFactory("AsyncRpcChannel")), EpollSocketChannel.class); } else { if (LOG.isDebugEnabled()) { LOG.debug("Create NioEventLoopGroup with maxThreads = " + maxThreads); } return new Pair<EventLoopGroup, Class<? extends Channel>>(new NioEventLoopGroup(maxThreads, Threads.newDaemonThreadFactory("AsyncRpcChannel")), NioSocketChannel.class); } }
@Parameters(name = "{index}: EventLoop={0}") public static Collection<Object[]> parameters() { List<Object[]> params = new ArrayList<>(); params.add(new Object[] { "nio" }); params.add(new Object[] { "perClientNio" }); if (JVM.isLinux() && JVM.isAmd64()) { params.add(new Object[] { "epoll" }); } return params; }
@BeforeClass public static void setUpBeforeClass() { NIO = new NioEventLoopGroup(); if (JVM.isLinux() && JVM.isAmd64()) { EPOLL = new EpollEventLoopGroup(); } }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) { return 0; } JVM jvm = new JVM(); return (int) jvm.getOpenFileDescriptorCount(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) { return 0; } JVM jvm = new JVM(); return (int) jvm.getMaxFileDescriptorCount(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) { return 0; } return (int) (new JVM().getSystemLoadAverage() * 100); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) { return 0; } return new JVM().getNumberOfRunningProcess(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) { return 0; } return (int) (new JVM().getFreeMemory() / (1024L * 1024L)); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) return 0; JVM jvm = new JVM(); return (int)jvm.getOpenFileDescriptorCount(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) return 0; JVM jvm = new JVM(); return (int)jvm.getMaxFileDescriptorCount(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) return 0; return (int)(new JVM().getSystemLoadAverage()*100); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) return 0; return new JVM().getNumberOfRunningProcess(); }
@Override public int getVal(Phase phase) { if (!JVM.isUnix()) return 0; return (int) (new JVM().getFreeMemory() / (1024L * 1024L)); }
@Override public int getVal(Phase phase) { if (JVM.isUnix() == false) return 0; JVM jvm = new JVM(); return (int)jvm.getOpenFileDescriptorCount(); }
@Override public int getVal(Phase phase) { if (JVM.isUnix() == false) return 0; JVM jvm = new JVM(); return (int)jvm.getMaxFileDescriptorCount(); }