List of usage examples for io.netty.channel DefaultEventLoop DefaultEventLoop
public DefaultEventLoop(EventLoopGroup parent, Executor executor)
From source file:com.linecorp.armeria.shared.EventLoopJmhExecutor.java
License:Apache License
@Override protected EventLoop newChild(Executor executor, Object... args) throws Exception { EventLoop eventLoop = new DefaultEventLoop(this, executor); eventLoop.submit(() -> CURRENT_EVENT_LOOP.set(eventLoop)).syncUninterruptibly(); return eventLoop; }
From source file:org.apache.bookkeeper.proto.BookieNettyServer.java
License:Apache License
BookieNettyServer(ServerConfiguration conf, RequestProcessor processor, ByteBufAllocator allocator) throws IOException, KeeperException, InterruptedException, BookieException { this.allocator = allocator; this.maxFrameSize = conf.getNettyMaxFrameSizeBytes(); this.conf = conf; this.requestProcessor = processor; this.authProviderFactory = AuthProviderFactoryFactory.newBookieAuthProviderFactory(conf); if (!conf.isDisableServerSocketBind()) { this.eventLoopGroup = EventLoopUtil.getServerEventLoopGroup(conf, new DefaultThreadFactory("bookie-io")); allChannels = new CleanupChannelGroup(eventLoopGroup); } else {// w w w . j a v a 2s . com this.eventLoopGroup = null; } if (conf.isEnableLocalTransport()) { jvmEventLoopGroup = new DefaultEventLoopGroup(conf.getServerNumIOThreads()) { @Override protected EventLoop newChild(Executor executor, Object... args) throws Exception { return new DefaultEventLoop(this, executor) { @Override protected Queue<Runnable> newTaskQueue(int maxPendingTasks) { if (conf.isBusyWaitEnabled()) { return new BlockingMpscQueue<>(Math.min(maxPendingTasks, 10_000)); } else { return super.newTaskQueue(maxPendingTasks); } } }; } }; // Enable CPU affinity on IO threads if (conf.isBusyWaitEnabled()) { for (int i = 0; i < conf.getServerNumIOThreads(); i++) { jvmEventLoopGroup.next().submit(() -> { try { CpuAffinity.acquireCore(); } catch (Throwable t) { LOG.warn("Failed to acquire CPU core for thread {}", Thread.currentThread().getName(), t.getMessage(), t); } }); } } allChannels = new CleanupChannelGroup(jvmEventLoopGroup); } else { jvmEventLoopGroup = null; } bookieAddress = Bookie.getBookieAddress(conf); if (conf.getListeningInterface() == null) { bindAddress = new InetSocketAddress(conf.getBookiePort()); } else { bindAddress = bookieAddress.getSocketAddress(); } listenOn(bindAddress, bookieAddress); }