本文整理了Java中io.netty.channel.epoll.EpollEventLoopGroup
类的一些代码示例,展示了EpollEventLoopGroup
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EpollEventLoopGroup
类的具体详情如下:
包路径:io.netty.channel.epoll.EpollEventLoopGroup
类名称:EpollEventLoopGroup
[英]EventLoopGroup which uses epoll under the covers. Because of this it only works on linux.
[中]EventLoopGroup,在封面下使用epoll。因此,它只能在linux上工作。
代码示例来源:origin: yu199195/Raincat
private EventLoopGroup createEventLoopGroup() {
try {
return new EpollEventLoopGroup(1);
} catch (final Throwable ex) {
return new NioEventLoopGroup(1);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public EventLoopGroup eventLoopGroup(int nThreads, ThreadFactory threadFactory, int ioRatio) {
EpollEventLoopGroup eventLoopGroup = new EpollEventLoopGroup(nThreads, threadFactory);
eventLoopGroup.setIoRatio(ioRatio);
return eventLoopGroup;
}
代码示例来源:origin: Netflix/zuul
clientToProxyBossPool = new EpollEventLoopGroup(
acceptorThreads,
new CategorizedThreadFactory(name + "-ClientToZuulAcceptor"));
clientToProxyWorkerPool = new EpollEventLoopGroup(
workerThreads,
workerExecutor,
clientToProxyBossPool = new NioEventLoopGroup(
acceptorThreads,
new CategorizedThreadFactory(name + "-ClientToZuulAcceptor"));
clientToProxyWorkerPool = new NioEventLoopGroup(
workerThreads,
workerExecutor,
DefaultSelectStrategyFactory.INSTANCE
);
((NioEventLoopGroup) clientToProxyWorkerPool).setIoRatio(90);
代码示例来源:origin: neo4j/neo4j
@Override
public EventLoopGroup createEventLoopGroup( int numberOfThreads, ThreadFactory threadFactory )
{
return new EpollEventLoopGroup( numberOfThreads, threadFactory );
}
代码示例来源:origin: io.reactivex/rxnetty
private EpollEventLoopGroup getNativeEventLoop() {
EpollEventLoopGroup eventLoopGroup = nativeEventLoop.get();
if (null == eventLoopGroup) {
EpollEventLoopGroup newEventLoopGroup = new EpollEventLoopGroup(childEventLoopCount,
new RxDefaultThreadFactory("rxnetty-epoll-eventloop"));
if (!nativeEventLoop.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
}
return nativeEventLoop.get();
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int workerIoRatio) {
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof NioEventLoopGroup) {
((NioEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int workerIoRatio) {
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
代码示例来源:origin: codeabovelab/haven-platform
@Override
public void destroy() throws Exception {
group.shutdownGracefully();
}
代码示例来源:origin: Netflix/zuul
clientToProxyBossPool = new EpollEventLoopGroup(
acceptorThreads,
new CategorizedThreadFactory(name + "-ClientToZuulAcceptor"));
clientToProxyWorkerPool = new EpollEventLoopGroup(
workerThreads,
workerExecutor,
clientToProxyBossPool = new NioEventLoopGroup(
acceptorThreads,
new CategorizedThreadFactory(name + "-ClientToZuulAcceptor"));
clientToProxyWorkerPool = new NioEventLoopGroup(
workerThreads,
workerExecutor,
DefaultSelectStrategyFactory.INSTANCE
);
((NioEventLoopGroup) clientToProxyWorkerPool).setIoRatio(90);
代码示例来源:origin: Graylog2/graylog2-server
private EventLoopGroup epollEventLoopGroup(int numThreads, Executor executor) {
return new EpollEventLoopGroup(numThreads, executor);
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
private EpollEventLoopGroup getNativeEventLoop() {
EpollEventLoopGroup eventLoopGroup = nativeEventLoop.get();
if (null == eventLoopGroup) {
EpollEventLoopGroup newEventLoopGroup = new EpollEventLoopGroup(childEventLoopCount,
new RxDefaultThreadFactory("rx-netty-epoll-eventloop"));
if (!nativeEventLoop.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
}
return nativeEventLoop.get();
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int workerIoRatio) {
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof NioEventLoopGroup) {
((NioEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int workerIoRatio) {
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
代码示例来源:origin: alipay/sofa-bolt
/**
* Create the right event loop according to current platform and system property, fallback to NIO when epoll not enabled.
*
* @param nThreads
* @param threadFactory
* @return an EventLoopGroup suitable for the current platform
*/
public static EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
return epollEnabled ? new EpollEventLoopGroup(nThreads, threadFactory)
: new NioEventLoopGroup(nThreads, threadFactory);
}
代码示例来源:origin: awslabs/mxnet-model-server
public static EventLoopGroup newEventLoopGroup(int threads) {
if (useNativeIo && Epoll.isAvailable()) {
return new EpollEventLoopGroup(threads);
} else if (useNativeIo && KQueue.isAvailable()) {
return new KQueueEventLoopGroup(threads);
}
NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(threads);
eventLoopGroup.setIoRatio(ConfigManager.getInstance().getIoRatio());
return eventLoopGroup;
}
代码示例来源:origin: apache/incubator-shardingsphere
private void groupsEpoll(final ServerBootstrap bootstrap) {
workerGroup = new EpollEventLoopGroup();
bootstrap.group(bossGroup, workerGroup)
.channel(EpollServerSocketChannel.class)
.option(EpollChannelOption.SO_BACKLOG, 128)
.option(EpollChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024 * 1024, 16 * 1024 * 1024))
.option(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.childOption(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.childOption(EpollChannelOption.TCP_NODELAY, true)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ServerHandlerInitializer());
}
代码示例来源:origin: mpusher/mpush
@SuppressWarnings("unused")
private void createEpollServer(Listener listener) {
EpollEventLoopGroup eventLoopGroup = new EpollEventLoopGroup(
1, new DefaultThreadFactory(ThreadNames.T_GATEWAY_WORKER)
);
eventLoopGroup.setIoRatio(100);
createServer(listener, eventLoopGroup, EpollDatagramChannel::new);
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
private EpollEventLoopGroup getNativeParentEventLoop() {
if (nativeParentEventLoop == nativeEventLoop) { // Means using same event loop for acceptor and worker pool.
return getNativeEventLoop();
}
EpollEventLoopGroup eventLoopGroup = nativeParentEventLoop.get();
if (null == eventLoopGroup) {
EpollEventLoopGroup newEventLoopGroup = new EpollEventLoopGroup(parentEventLoopCount,
new RxDefaultThreadFactory("rx-netty-epoll-eventloop"));
if (!nativeParentEventLoop.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
}
return nativeParentEventLoop.get();
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int bossIoRatio, int workerIoRatio) {
EventLoopGroup boss = boss();
if (boss instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) boss).setIoRatio(bossIoRatio);
} else if (boss instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) boss).setIoRatio(bossIoRatio);
} else if (boss instanceof NioEventLoopGroup) {
((NioEventLoopGroup) boss).setIoRatio(bossIoRatio);
}
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof NioEventLoopGroup) {
((NioEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
public void setIoRatio(int bossIoRatio, int workerIoRatio) {
EventLoopGroup boss = boss();
if (boss instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) boss).setIoRatio(bossIoRatio);
} else if (boss instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) boss).setIoRatio(bossIoRatio);
}
EventLoopGroup worker = worker();
if (worker instanceof EpollEventLoopGroup) {
((EpollEventLoopGroup) worker).setIoRatio(workerIoRatio);
} else if (worker instanceof KQueueEventLoopGroup) {
((KQueueEventLoopGroup) worker).setIoRatio(workerIoRatio);
}
}
内容来源于网络,如有侵权,请联系作者删除!