本文整理了Java中io.netty.channel.epoll.EpollEventLoopGroup.<init>()
方法的一些代码示例,展示了EpollEventLoopGroup.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EpollEventLoopGroup.<init>()
方法的具体详情如下:
包路径:io.netty.channel.epoll.EpollEventLoopGroup
类名称:EpollEventLoopGroup
方法名:<init>
[英]Create a new instance using the default number of threads and the default ThreadFactory.
[中]使用默认线程数和默认ThreadFactory创建新实例。
代码示例来源:origin: neo4j/neo4j
@Override
public EventLoopGroup createEventLoopGroup( int numberOfThreads, ThreadFactory threadFactory )
{
return new EpollEventLoopGroup( numberOfThreads, threadFactory );
}
代码示例来源:origin: Graylog2/graylog2-server
private EventLoopGroup epollEventLoopGroup(int numThreads, Executor executor) {
return new EpollEventLoopGroup(numThreads, executor);
}
代码示例来源: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: apache/incubator-shardingsphere
private EventLoopGroup createEventLoopGroup() {
return Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
}
代码示例来源:origin: apache/incubator-shardingsphere
private EventLoopGroup createEventLoopGroup() {
return Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
}
代码示例来源:origin: apache/zookeeper
/**
* If {@link Epoll#isAvailable()} <code>== true</code>, returns a new
* {@link EpollEventLoopGroup}, otherwise returns a new
* {@link NioEventLoopGroup}.
* @return a new {@link EventLoopGroup}.
*/
public static EventLoopGroup newNioOrEpollEventLoopGroup() {
if (Epoll.isAvailable()) {
return new EpollEventLoopGroup();
} else {
return new NioEventLoopGroup();
}
}
代码示例来源:origin: apache/pulsar
/**
* @return an EventLoopGroup suitable for the current platform
*/
public static EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
if (Epoll.isAvailable()) {
return new EpollEventLoopGroup(nThreads, threadFactory);
} else {
// Fallback to NIO
return new NioEventLoopGroup(nThreads, threadFactory);
}
}
代码示例来源: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: 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: lettuce-io/lettuce-core
@Override
public EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
checkForEpollLibrary();
return new EpollEventLoopGroup(nThreads, threadFactory);
}
代码示例来源:origin: yu199195/Raincat
private void groupsEpoll(final ServerBootstrap bootstrap, final int workThreads) {
workerGroup = new EpollEventLoopGroup(workThreads);
bootstrap.group(bossGroup, workerGroup)
.channel(EpollServerSocketChannel.class)
.option(EpollChannelOption.TCP_CORK, true)
.option(EpollChannelOption.SO_KEEPALIVE, true)
.option(EpollChannelOption.SO_BACKLOG, 100)
.option(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.childOption(EpollChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(nettyServerHandlerInitializer);
}
代码示例来源:origin: ReactiveX/RxNetty
private EventLoopGroup getNativeEventLoop() {
EventLoopGroup eventLoopGroup = nativeEventLoop.get();
if (null == eventLoopGroup) {
EventLoopGroup newEventLoopGroup = new EpollEventLoopGroup(childEventLoopCount,
new RxDefaultThreadFactory( "rxnetty-epoll-eventloop"));
if (!nativeEventLoop.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
}
return nativeEventLoop.get();
}
代码示例来源:origin: testcontainers/testcontainers-java
public EventLoopGroup epollGroup() {
EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup(0, createThreadFactory());
ChannelFactory<EpollDomainSocketChannel> factory = () -> configure(new EpollDomainSocketChannel());
bootstrap.group(epollEventLoopGroup).channelFactory(factory).handler(new ChannelInitializer<UnixChannel>() {
@Override
protected void initChannel(final UnixChannel channel) throws Exception {
channel.pipeline().addLast(new HttpClientCodec());
channel.pipeline().addLast(new HttpContentDecompressor());
}
});
return epollEventLoopGroup;
}
代码示例来源:origin: mrniko/netty-socketio
protected void initGroups() {
if (configCopy.isUseLinuxNativeEpoll()) {
bossGroup = new EpollEventLoopGroup(configCopy.getBossThreads());
workerGroup = new EpollEventLoopGroup(configCopy.getWorkerThreads());
} else {
bossGroup = new NioEventLoopGroup(configCopy.getBossThreads());
workerGroup = new NioEventLoopGroup(configCopy.getWorkerThreads());
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 得到服务端业务线程池
*
* @param config 服务端配置
* @param executor 业务线程池
* @return 服务端业务线程池
*/
public static EventLoopGroup getServerBizEventLoopGroup(ServerTransportConfig config, Executor executor) {
int bizThreads = config.getBizMaxThreads();
return config.isUseEpoll() ?
new EpollEventLoopGroup(config.getBizMaxThreads(), executor) :
new NioEventLoopGroup(bizThreads, executor);
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 得到服务端业务线程池
*
* @param config 服务端配置
* @param executor 业务线程池
* @return 服务端业务线程池
*/
public static EventLoopGroup getServerBizEventLoopGroup(ServerTransportConfig config, Executor executor) {
int bizThreads = config.getBizMaxThreads();
return config.isUseEpoll() ?
new EpollEventLoopGroup(config.getBizMaxThreads(), executor) :
new NioEventLoopGroup(bizThreads, executor);
}
代码示例来源:origin: lets-blade/blade
static NettyServerGroup group(int threadCount, int workers) {
var bossGroup = new EpollEventLoopGroup(threadCount, new NamedThreadFactory("epoll-boss@"));
var workerGroup = new EpollEventLoopGroup(workers, new NamedThreadFactory("epoll-worker@"));
return NettyServerGroup.builder().boosGroup(bossGroup).workerGroup(workerGroup).socketChannel(EpollServerSocketChannel.class).build();
}
代码示例来源:origin: lets-blade/blade
static NettyServerGroup group(int threadCount, int workers) {
var bossGroup = new EpollEventLoopGroup(threadCount, new NamedThreadFactory("epoll-boss@"));
var workerGroup = new EpollEventLoopGroup(workers, new NamedThreadFactory("epoll-worker@"));
return NettyServerGroup.builder().boosGroup(bossGroup).workerGroup(workerGroup).socketChannel(EpollServerSocketChannel.class).build();
}
代码示例来源: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: mpusher/mpush
private void createEpollClient(Listener listener) {
EpollEventLoopGroup workerGroup = new EpollEventLoopGroup(
getWorkThreadNum(), new DefaultThreadFactory(ThreadNames.T_TCP_CLIENT)
);
workerGroup.setIoRatio(getIoRate());
createClient(listener, workerGroup, EpollSocketChannel::new);
}
内容来源于网络,如有侵权,请联系作者删除!