io.netty.channel.epoll.EpollEventLoopGroup Java Examples
The following examples show how to use
io.netty.channel.epoll.EpollEventLoopGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncHttpService.java From arcusplatform with Apache License 2.0 | 7 votes |
static void start() { final AtomicLong counter = new AtomicLong(); ThreadFactory tf = new ThreadFactory() { @Override public Thread newThread(@Nullable Runnable runnable) { Thread thr = new Thread(runnable); thr.setName("ahc" + counter.getAndIncrement()); thr.setDaemon(true); return thr; } }; useEpoll = Epoll.isAvailable(); useOpenSsl = false; evlg = useEpoll ? new EpollEventLoopGroup(2,tf) : new NioEventLoopGroup(2,tf); DefaultAsyncHttpClientConfig config = builder().build(); client = new DefaultAsyncHttpClient(config); }
Example #2
Source File: NettyNetworking.java From Cleanstone with MIT License | 6 votes |
@Override public void start() { bossGroup = epoll ? new EpollEventLoopGroup() : new NioEventLoopGroup(); workerGroup = epoll ? new EpollEventLoopGroup() : new NioEventLoopGroup(); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup) .channel(epoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class) .childHandler(new ServerChannelInitializer(this)) .option(ChannelOption.SO_BACKLOG, socketBacklog) .childOption(ChannelOption.SO_KEEPALIVE, socketKeepAlive); bootstrap.localAddress(this.getAddress(), this.getPort()); bootstrap.bind().addListener(future -> { if (future.isSuccess()) { log.info(CleanstoneServer.getMessage("net.netty.bind-successful", protocol.getClass().getSimpleName(), getAddress(), getPort() + "")); } else { log.error(CleanstoneServer.getMessage("net.netty.bind-failure", getAddress().getHostAddress(), getPort() + ""), future.cause()); } }); running = true; }
Example #3
Source File: HttpServerBoot.java From elastic-rabbitmq with MIT License | 6 votes |
public void run() throws Exception { ServerBootstrap b = new ServerBootstrap(); try { if (isEpollAvailable) { b.group(new EpollEventLoopGroup(this.conf.getEventLoopThreadCount())) .channel(EpollServerSocketChannel.class); } else { b.group(new NioEventLoopGroup(this.conf.getEventLoopThreadCount())) .channel(NioServerSocketChannel.class); } b.childHandler(new DefaultServerInitializer(conf, context)) .option(ChannelOption.SO_BACKLOG, conf.getBacklog()) .option(ChannelOption.SO_REUSEADDR, true); Channel ch = b.bind(conf.getPort()).sync().channel(); ch.closeFuture().sync(); } finally { } }
Example #4
Source File: UdpServerChannel.java From UdpServerSocketChannel with GNU Lesser General Public License v3.0 | 6 votes |
public UdpServerChannel(int ioThreads) { if (ioThreads < 1) { throw new IllegalArgumentException("IO threads cound can't be less than 1"); } boolean epollAvailabe = Epoll.isAvailable(); if (!epollAvailabe) { ioThreads = 1; } group = epollAvailabe ? new EpollEventLoopGroup(ioThreads) : new NioEventLoopGroup(ioThreads); Class<? extends DatagramChannel> channel = epollAvailabe ? EpollDatagramChannel.class : NioDatagramChannel.class; ChannelInitializer<Channel> initializer = new ChannelInitializer<Channel>() { final ReadRouteChannelHandler ioReadRoute = new ReadRouteChannelHandler(); @Override protected void initChannel(Channel ioChannel) throws Exception { ioChannel.pipeline().addLast(ioReadRoute); } }; while (ioThreads-- > 0) { Bootstrap ioBootstrap = new Bootstrap().group(group).channel(channel).handler(initializer); if (epollAvailabe) { ioBootstrap.option(UnixChannelOption.SO_REUSEPORT, true); } ioBootstraps.add(ioBootstrap); } }
Example #5
Source File: ShardingSphereProxy.java From shardingsphere with Apache License 2.0 | 6 votes |
/** * Start ShardingSphere-Proxy. * * @param port port */ @SneakyThrows(InterruptedException.class) public void start(final int port) { try { ServerBootstrap bootstrap = new ServerBootstrap(); bossGroup = createEventLoopGroup(); if (bossGroup instanceof EpollEventLoopGroup) { groupsEpoll(bootstrap); } else { groupsNio(bootstrap); } ChannelFuture future = bootstrap.bind(port).sync(); future.channel().closeFuture().sync(); } finally { workerGroup.shutdownGracefully(); bossGroup.shutdownGracefully(); BackendExecutorContext.getInstance().getExecutorKernel().close(); } }
Example #6
Source File: UDPServerSocket.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public UDPServerSocket(ThreadedLogger logger, int port, String interfaz) { this.logger = logger; try { bootstrap = new Bootstrap() .channel(EPOLL ? EpollDatagramChannel.class : NioDatagramChannel.class) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .handler(this) .group(EPOLL ? new EpollEventLoopGroup() : new NioEventLoopGroup()); this.logger.info("Epoll Status is " + EPOLL); channel = bootstrap.bind(interfaz, port).sync().channel(); } catch (Exception e) { this.logger.critical("**** FAILED TO BIND TO " + interfaz + ":" + port + "!"); this.logger.critical("Perhaps a server is already running on that port?"); System.exit(1); } }
Example #7
Source File: SocketChannelResolver.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
/** * Attempts to determine the {@link ChannelFactory} class that corresponds to the given * event loop group. * * @param eventLoopGroup the event loop group to determine the {@link ChannelFactory} for * @return A {@link ChannelFactory} instance for the given event loop group. */ @SuppressWarnings("unchecked") public static ChannelFactory<? extends Channel> resolveSocketChannelFactory(EventLoopGroup eventLoopGroup) { if (eventLoopGroup instanceof DelegatingEventLoopGroup) { return resolveSocketChannelFactory(((DelegatingEventLoopGroup) eventLoopGroup).getDelegate()); } if (eventLoopGroup instanceof NioEventLoopGroup) { return NioSocketChannel::new; } if (eventLoopGroup instanceof EpollEventLoopGroup) { return EpollSocketChannel::new; } String socketFqcn = KNOWN_EL_GROUPS.get(eventLoopGroup.getClass().getName()); if (socketFqcn == null) { throw new IllegalArgumentException("Unknown event loop group : " + eventLoopGroup.getClass()); } return invokeSafely(() -> new ReflectiveChannelFactory(Class.forName(socketFqcn))); }
Example #8
Source File: NettyHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 获取客户端IO线程池 * * @return 客户端IO线程池 */ public synchronized static EventLoopGroup getClientIOEventLoopGroup() { if (clientIOEventLoopGroup != null && clientIOEventLoopGroup.isShutdown()) { clientIOEventLoopGroup = null; } if (clientIOEventLoopGroup == null) { int clientIoThreads = getIntValue(TRANSPORT_CLIENT_IO_THREADS); int threads = clientIoThreads > 0 ? clientIoThreads : // 用户配置 Math.max(4, SystemInfo.getCpuCores() + 1); // 默认cpu+1,至少4个 NamedThreadFactory threadName = new NamedThreadFactory("CLI-IO", true); boolean useEpoll = getBooleanValue(TRANSPORT_USE_EPOLL); clientIOEventLoopGroup = useEpoll ? new EpollEventLoopGroup(threads, threadName) : new NioEventLoopGroup(threads, threadName); refCounter.putIfAbsent(clientIOEventLoopGroup, new AtomicInteger(0)); // SelectStrategyFactory 未设置 } refCounter.get(clientIOEventLoopGroup).incrementAndGet(); return clientIOEventLoopGroup; }
Example #9
Source File: NettyHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 得到服务端IO线程池 * * @param config 服务端配置 * @return 服务端Boss线程池 */ public static EventLoopGroup getServerIoEventLoopGroup(ServerTransportConfig config) { String type = config.getProtocolType(); EventLoopGroup ioGroup = serverIoGroups.get(type); if (ioGroup == null) { synchronized (NettyHelper.class) { ioGroup = serverIoGroups.get(config.getProtocolType()); if (ioGroup == null) { int ioThreads = config.getIoThreads(); ioThreads = ioThreads <= 0 ? Math.max(8, SystemInfo.getCpuCores() + 1) : ioThreads; NamedThreadFactory threadName = new NamedThreadFactory("SEV-IO-" + config.getPort(), config.isDaemon()); ioGroup = config.isUseEpoll() ? new EpollEventLoopGroup(ioThreads, threadName) : new NioEventLoopGroup(ioThreads, threadName); serverIoGroups.put(type, ioGroup); refCounter.putIfAbsent(ioGroup, new AtomicInteger(0)); } } } refCounter.get(ioGroup).incrementAndGet(); return ioGroup; }
Example #10
Source File: NettyHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 得到服务端Boss线程池 * * @param config 服务端配置 * @return 服务端Boss线程池 */ public static EventLoopGroup getServerBossEventLoopGroup(ServerTransportConfig config) { String type = config.getProtocolType(); EventLoopGroup bossGroup = serverBossGroups.get(type); if (bossGroup == null) { synchronized (NettyHelper.class) { bossGroup = serverBossGroups.get(config.getProtocolType()); if (bossGroup == null) { int bossThreads = config.getBossThreads(); bossThreads = bossThreads <= 0 ? Math.max(4, SystemInfo.getCpuCores() / 2) : bossThreads; NamedThreadFactory threadName = new NamedThreadFactory("SEV-BOSS-" + config.getPort(), config.isDaemon()); bossGroup = config.isUseEpoll() ? new EpollEventLoopGroup(bossThreads, threadName) : new NioEventLoopGroup(bossThreads, threadName); serverBossGroups.put(type, bossGroup); refCounter.putIfAbsent(bossGroup, new AtomicInteger(0)); } } } refCounter.get(bossGroup).incrementAndGet(); return bossGroup; }
Example #11
Source File: NettyServer.java From krpc with Apache License 2.0 | 6 votes |
@Override public void dump(Map<String, Object> metrics) { if( nativeNetty) { metrics.put("krpc.server.nativeNetty", true); metrics.put("krpc.server.boss.threads", ((EpollEventLoopGroup)bossGroup).executorCount()); metrics.put("krpc.server.worker.threads", ((EpollEventLoopGroup)workerGroup).executorCount()); } else { metrics.put("krpc.server.boss.threads", ((NioEventLoopGroup)bossGroup).executorCount()); metrics.put("krpc.server.worker.threads", ((NioEventLoopGroup)workerGroup).executorCount()); } metrics.put("krpc.server.conns.size",conns.size()); metrics.put("krpc.server.port",port); metrics.put("krpc.server.host",host); metrics.put("krpc.server.idleSeconds",idleSeconds); metrics.put("krpc.server.maxPackageSize",maxPackageSize); metrics.put("krpc.server.maxConns",maxConns); metrics.put("krpc.server.backlog",backlog); }
Example #12
Source File: NettyServer.java From Kepler with GNU Lesser General Public License v3.0 | 6 votes |
/** * Create the Netty sockets. */ public void createSocket() { int threads = Runtime.getRuntime().availableProcessors(); this.bossGroup = (Epoll.isAvailable()) ? new EpollEventLoopGroup(threads) : new NioEventLoopGroup(threads); this.workerGroup = (Epoll.isAvailable()) ? new EpollEventLoopGroup(threads) : new NioEventLoopGroup(threads); this.bootstrap.group(bossGroup, workerGroup) .channel((Epoll.isAvailable()) ? EpollServerSocketChannel.class : NioServerSocketChannel.class) .childHandler(new NettyChannelInitializer(this)) .option(ChannelOption.SO_BACKLOG, BACK_LOG) .childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.SO_KEEPALIVE, true) .childOption(ChannelOption.SO_RCVBUF, BUFFER_SIZE) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(BUFFER_SIZE)) .childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator(true)); }
Example #13
Source File: MusServer.java From Kepler with GNU Lesser General Public License v3.0 | 6 votes |
/** * Create the Netty sockets. */ public void createSocket() { int threads = Runtime.getRuntime().availableProcessors(); this.bossGroup = (Epoll.isAvailable()) ? new EpollEventLoopGroup(threads) : new NioEventLoopGroup(threads); this.workerGroup = (Epoll.isAvailable()) ? new EpollEventLoopGroup(threads) : new NioEventLoopGroup(threads); this.bootstrap.group(bossGroup, workerGroup) .channel((Epoll.isAvailable()) ? EpollServerSocketChannel.class : NioServerSocketChannel.class) .childHandler(new MusChannelInitializer(this)) .option(ChannelOption.SO_BACKLOG, BACK_LOG) .childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.SO_KEEPALIVE, true) .childOption(ChannelOption.SO_RCVBUF, BUFFER_SIZE) .childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(BUFFER_SIZE)) .childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator(true)); }
Example #14
Source File: DFSocketManager.java From dfactor with MIT License | 6 votes |
protected ChannelFuture doTcpConntecSync(DFTcpClientCfg cfg, EventLoopGroup ioGroup, ChannelHandler handler){ if(ioGroup == null){ return null; } Bootstrap boot = new Bootstrap(); boot.group(ioGroup) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .option(ChannelOption.SO_KEEPALIVE, cfg.isKeepAlive()) .option(ChannelOption.SO_RCVBUF, cfg.getSoRecvBufLen()) .option(ChannelOption.SO_SNDBUF, cfg.getSoSendBufLen()) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int)cfg.getConnTimeout()) .option(ChannelOption.TCP_NODELAY, cfg.isTcpNoDelay()) .handler(new TcpHandlerInit(false, cfg.getTcpProtocol(), cfg.getTcpMsgMaxLength(), 0, 0, cfg.getWsUri(), null, cfg.getDecoder(), cfg.getEncoder(), cfg.getUserHandler(), cfg.getSslCfg() , cfg.getReqData(), handler)); if(ioGroup instanceof EpollEventLoopGroup){ boot.channel(EpollSocketChannel.class); }else{ boot.channel(NioSocketChannel.class); } ChannelFuture future = boot.connect(cfg.host, cfg.port); return future; }
Example #15
Source File: TransportCheck.java From dremio-oss with Apache License 2.0 | 5 votes |
public static EventLoopGroup createEventLoopGroup(int nThreads, String prefix) { if(SUPPORTS_EPOLL){ return new EpollEventLoopGroup(nThreads, newThreadFactory(prefix)); }else{ return new NioEventLoopGroup(nThreads, newThreadFactory(prefix)); } }
Example #16
Source File: Connector.java From multi-model-server with Apache License 2.0 | 5 votes |
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; }
Example #17
Source File: NettyTCPClient.java From mpush with Apache License 2.0 | 5 votes |
private void createEpollClient(Listener listener) { EpollEventLoopGroup workerGroup = new EpollEventLoopGroup( getWorkThreadNum(), new DefaultThreadFactory(ThreadNames.T_TCP_CLIENT) ); workerGroup.setIoRatio(getIoRate()); createClient(listener, workerGroup, EpollSocketChannel::new); }
Example #18
Source File: HDBClient.java From herddb with Apache License 2.0 | 5 votes |
public HDBClient(ClientConfiguration configuration, StatsLogger statsLogger) { this.configuration = configuration; this.statsLogger = statsLogger.scope("hdbclient"); int corePoolSize = configuration.getInt(ClientConfiguration.PROPERTY_CLIENT_CALLBACKS, ClientConfiguration.PROPERTY_CLIENT_CALLBACKS_DEFAULT); this.maxOperationRetryCount = configuration.getInt(ClientConfiguration.PROPERTY_MAX_OPERATION_RETRY_COUNT, ClientConfiguration.PROPERTY_MAX_OPERATION_RETRY_COUNT_DEFAULT); this.operationRetryDelay = configuration.getInt(ClientConfiguration.PROPERTY_OPERATION_RETRY_DELAY, ClientConfiguration.PROPERTY_OPERATION_RETRY_DELAY_DEFAULT); this.thredpool = new ThreadPoolExecutor(corePoolSize, Integer.MAX_VALUE, 120L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), (Runnable r) -> { Thread t = new FastThreadLocalThread(r, "hdb-client"); t.setDaemon(true); return t; }); this.networkGroup = NetworkUtils.isEnableEpoolNative() ? new EpollEventLoopGroup() : new NioEventLoopGroup(); this.localEventsGroup = new DefaultEventLoopGroup(); String mode = configuration.getString(ClientConfiguration.PROPERTY_MODE, ClientConfiguration.PROPERTY_MODE_LOCAL); switch (mode) { case ClientConfiguration.PROPERTY_MODE_LOCAL: case ClientConfiguration.PROPERTY_MODE_STANDALONE: this.clientSideMetadataProvider = new StaticClientSideMetadataProvider( configuration.getString(ClientConfiguration.PROPERTY_SERVER_ADDRESS, ClientConfiguration.PROPERTY_SERVER_ADDRESS_DEFAULT), configuration.getInt(ClientConfiguration.PROPERTY_SERVER_PORT, ClientConfiguration.PROPERTY_SERVER_PORT_DEFAULT), configuration.getBoolean(ClientConfiguration.PROPERTY_SERVER_SSL, ClientConfiguration.PROPERTY_SERVER_SSL_DEFAULT) ); break; case ClientConfiguration.PROPERTY_MODE_CLUSTER: this.clientSideMetadataProvider = new ZookeeperClientSideMetadataProvider( configuration.getString(ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS_DEFAULT), configuration.getInt(ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT_DEFAULT), configuration.getString(ClientConfiguration.PROPERTY_ZOOKEEPER_PATH, ClientConfiguration.PROPERTY_ZOOKEEPER_PATH_DEFAULT) ); break; default: throw new IllegalStateException(mode); } }
Example #19
Source File: Server.java From rpc-benchmark with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws InterruptedException { if (Epoll.isAvailable()) { doRun(// new EpollEventLoopGroup(), // EpollServerSocketChannel.class, // true); } else { doRun(// new NioEventLoopGroup(), // NioServerSocketChannel.class, // false); } }
Example #20
Source File: HttpBlobStore.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
public static HttpBlobStore create( DomainSocketAddress domainSocketAddress, URI uri, int timeoutMillis, int remoteMaxConnections, @Nullable final Credentials creds) throws ConfigurationException, URISyntaxException, SSLException { if (KQueue.isAvailable()) { return new HttpBlobStore( KQueueEventLoopGroup::new, KQueueDomainSocketChannel.class, uri, timeoutMillis, remoteMaxConnections, creds, domainSocketAddress); } else if (Epoll.isAvailable()) { return new HttpBlobStore( EpollEventLoopGroup::new, EpollDomainSocketChannel.class, uri, timeoutMillis, remoteMaxConnections, creds, domainSocketAddress); } else { throw new ConfigurationException("Unix domain sockets are unsupported on this platform"); } }
Example #21
Source File: NettyClient.java From krpc with Apache License 2.0 | 5 votes |
@Override public void dump(Map<String, Object> metrics) { if( nativeNetty) { metrics.put("krpc.client.nativeNetty", true); metrics.put("krpc.client.worker.threads", ((EpollEventLoopGroup)workerGroup).executorCount()); } else { metrics.put("krpc.client.worker.threads", ((NioEventLoopGroup)workerGroup).executorCount()); } metrics.put("krpc.client.conns.size",connIdMap.size()); metrics.put("krpc.client.pingSeconds",pingSeconds); metrics.put("krpc.client.maxPackageSize",maxPackageSize); metrics.put("krpc.client.connectTimeout",connectTimeout); metrics.put("krpc.client.reconnectSeconds",reconnectSeconds); int n = reconnectingConns.size(); if( n > 0 ) { List<HealthStatus> healthStatusList = new ArrayList<>(); for(String connId: reconnectingConns.keySet()) { String addr = getAddr(connId); int p = addr.lastIndexOf(":"); int serviceId = TypeSafe.anyToInt(addr.substring(p+1).substring(1)); // 取端口,去掉第一个字符,一般端口格式是 7xxx String alarmId = serviceId + "002"; String targetAddr = serviceId+":"+addr; String msg = "krpc connection failed from " + alarm.getAlarmPrefix(); alarm.alarm4rpc(alarmId, msg,"rpc",targetAddr); HealthStatus healthStatus = new HealthStatus(alarmId, false, msg,"rpc",targetAddr); healthStatusList.add(healthStatus); } lastHealthStatusList.set(healthStatusList); metrics.put("krpc.client.reconnectingConns", n); } }
Example #22
Source File: NettyHttpServer.java From krpc with Apache License 2.0 | 5 votes |
@Override public void dump(Map<String, Object> metrics) { if( nativeNetty) { metrics.put("krpc.webserver.nativeNetty", true); metrics.put("krpc.webserver.boss.threads", ((EpollEventLoopGroup)bossGroup).executorCount()); metrics.put("krpc.webserver.worker.threads", ((EpollEventLoopGroup)workerGroup).executorCount()); } else { metrics.put("krpc.webserver.boss.threads", ((NioEventLoopGroup)bossGroup).executorCount()); metrics.put("krpc.webserver.worker.threads", ((NioEventLoopGroup)workerGroup).executorCount()); } metrics.put("krpc.webserver.conns.size",conns.size()); metrics.put("krpc.webserver.port",port); metrics.put("krpc.webserver.host",host); metrics.put("krpc.webserver.idleSeconds",idleSeconds); metrics.put("krpc.webserver.idleSecondsForDownload",idleSecondsForDownload); metrics.put("krpc.webserver.maxConns",maxConns); metrics.put("krpc.webserver.backlog",backlog); metrics.put("krpc.webserver.maxInitialLineLength",maxInitialLineLength); metrics.put("krpc.webserver.maxHeaderSize",maxHeaderSize); metrics.put("krpc.webserver.maxChunkSize",maxChunkSize); metrics.put("krpc.webserver.maxContentLength",maxContentLength); metrics.put("krpc.webserver.maxUploadLength",maxUploadLength); }
Example #23
Source File: NettyTransport.java From async-gamequery-lib with MIT License | 5 votes |
/** * <p>A factory method that manufactures {@link EventLoopGroup} based on {@link ChannelType}. If the platform * supports * Epoll and the channel type is NIO, it will return {@link EpollEventLoopGroup} instead.</p> * * @param type * The {@link ChannelType} that will determine which {@link EventLoopGroup} will be returned. * * @return The concrete {@link EventLoopGroup} instance that will be used by the transport. */ private EventLoopGroup createEventLoopGroup(ChannelType type) { switch (type) { case NIO_TCP: case NIO_UDP: if (Epoll.isAvailable()) { log.debug("Using EpollEventLoopGroup"); return new EpollEventLoopGroup(8, executorService, DefaultSelectStrategyFactory.INSTANCE); } return new NioEventLoopGroup(8, executorService, SelectorProvider.provider(), DefaultSelectStrategyFactory.INSTANCE); } return null; }
Example #24
Source File: DefaultLoopEpoll.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override public boolean supportGroup(EventLoopGroup group) { if (group instanceof ColocatedEventLoopGroup) { group = ((ColocatedEventLoopGroup) group).get(); } return group instanceof EpollEventLoopGroup; }
Example #25
Source File: HttpAgent.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
private static EventLoopGroup eventLoopGroup( final OptimalTransport optimalTransport, final int processorPoolSize, final Logger logger) { switch (optimalTransport) { case Epoll: logger.debug("HttpAgent using EpollEventLoopGroup " + processorPoolSize); return new EpollEventLoopGroup(processorPoolSize); case NIO: default: logger.debug("HttpAgent using NioEventLoopGroup " + processorPoolSize); return new NioEventLoopGroup(processorPoolSize); } }
Example #26
Source File: HttpAgent.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
private static EventLoopGroup eventLoopGroup( final OptimalTransport optimalTransport, final Logger logger) { switch (optimalTransport) { case Epoll: logger.debug("HttpAgent using EpollEventLoopGroup"); return new EpollEventLoopGroup(); case NIO: default: logger.debug("HttpAgent using NioEventLoopGroup"); return new NioEventLoopGroup(); } }
Example #27
Source File: ConnectionPoolImpl.java From pravega with Apache License 2.0 | 5 votes |
private EventLoopGroup getEventLoopGroup() { if (Epoll.isAvailable()) { return new EpollEventLoopGroup(); } else { log.warn("Epoll not available. Falling back on NIO."); return new NioEventLoopGroup(); } }
Example #28
Source File: TransportServerSupport.java From journalkeeper with Apache License 2.0 | 5 votes |
protected EventLoopGroup newAcceptEventGroup() { NamedThreadFactory threadFactory = new NamedThreadFactory("Transport-Accept-IO-LoopGroup"); if (Epoll.isAvailable()) { return new EpollEventLoopGroup(serverConfig.getAcceptThread(), threadFactory); } else { return new NioEventLoopGroup(serverConfig.getAcceptThread(), threadFactory); } }
Example #29
Source File: AbstractNettyClient.java From spring-boot-protocol with Apache License 2.0 | 5 votes |
protected EventLoopGroup newWorkerEventLoopGroup() { EventLoopGroup worker; if(enableEpoll){ EpollEventLoopGroup epollWorker = new EpollEventLoopGroup(ioThreadCount,new ThreadFactoryX("Epoll",namePre+"Client-Worker")); // epollWorker.setIoRatio(ioRatio); worker = epollWorker; }else { NioEventLoopGroup nioWorker = new NioEventLoopGroup(ioThreadCount,new ThreadFactoryX("NIO",namePre+"Client-Worker")); nioWorker.setIoRatio(ioRatio); worker = nioWorker; } return worker; }
Example #30
Source File: Client.java From java-dcp-client with Apache License 2.0 | 5 votes |
private static EventLoopGroup newEventLoopGroup() { if (Epoll.isAvailable()) { LOGGER.info("Using Netty epoll native transport."); return new EpollEventLoopGroup(threadFactory); } if (KQueue.isAvailable()) { LOGGER.info("Using Netty kqueue native transport."); return new KQueueEventLoopGroup(threadFactory); } LOGGER.info("Using Netty NIO transport."); return new NioEventLoopGroup(threadFactory); }