use of io.netty.channel.epoll.EpollEventLoopGroup in project flink by apache.
the class NettyClient method initEpollBootstrap.
private void initEpollBootstrap() {
// Add the server port number to the name in order to distinguish
// multiple clients running on the same host.
String name = NettyConfig.CLIENT_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";
EpollEventLoopGroup epollGroup = new EpollEventLoopGroup(config.getClientNumThreads(), NettyServer.getNamedThreadFactory(name));
bootstrap.group(epollGroup).channel(EpollSocketChannel.class);
}
use of io.netty.channel.epoll.EpollEventLoopGroup in project netty-socketio by mrniko.
the class SocketIOServer method initGroups.
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());
}
}
use of io.netty.channel.epoll.EpollEventLoopGroup in project cassandra by apache.
the class NativeTransportService method initialize.
/**
* Creates netty thread pools and event loops.
*/
@VisibleForTesting
synchronized void initialize() {
if (initialized)
return;
// prepare netty resources
eventExecutorGroup = new RequestThreadPoolExecutor();
if (useEpoll()) {
workerGroup = new EpollEventLoopGroup();
logger.info("Netty using native Epoll event loop");
} else {
workerGroup = new NioEventLoopGroup();
logger.info("Netty using Java NIO event loop");
}
int nativePort = DatabaseDescriptor.getNativeTransportPort();
int nativePortSSL = DatabaseDescriptor.getNativeTransportPortSSL();
InetAddress nativeAddr = DatabaseDescriptor.getRpcAddress();
org.apache.cassandra.transport.Server.Builder builder = new org.apache.cassandra.transport.Server.Builder().withEventExecutor(eventExecutorGroup).withEventLoopGroup(workerGroup).withHost(nativeAddr);
if (!DatabaseDescriptor.getClientEncryptionOptions().enabled) {
servers = Collections.singleton(builder.withSSL(false).withPort(nativePort).build());
} else {
if (nativePort != nativePortSSL) {
// user asked for dedicated ssl port for supporting both non-ssl and ssl connections
servers = Collections.unmodifiableList(Arrays.asList(builder.withSSL(false).withPort(nativePort).build(), builder.withSSL(true).withPort(nativePortSSL).build()));
} else {
// ssl only mode using configured native port
servers = Collections.singleton(builder.withSSL(true).withPort(nativePort).build());
}
}
// register metrics
ClientMetrics.instance.addCounter("connectedNativeClients", () -> {
int ret = 0;
for (Server server : servers) ret += server.getConnectedClients();
return ret;
});
AuthMetrics.init();
initialized = true;
}
use of io.netty.channel.epoll.EpollEventLoopGroup in project grpc-java by grpc.
the class Utils method newNettyClientChannel.
private static NettyChannelBuilder newNettyClientChannel(Transport transport, SocketAddress address, boolean tls, boolean testca, int flowControlWindow, boolean useDefaultCiphers) throws IOException {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(address).flowControlWindow(flowControlWindow);
if (tls) {
builder.negotiationType(NegotiationType.TLS);
SslContext sslContext = null;
if (testca) {
File cert = TestUtils.loadCert("ca.pem");
SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient().trustManager(cert);
if (transport == Transport.NETTY_NIO) {
sslContextBuilder = GrpcSslContexts.configure(sslContextBuilder, SslProvider.JDK);
} else {
// Native transport with OpenSSL
sslContextBuilder = GrpcSslContexts.configure(sslContextBuilder, SslProvider.OPENSSL);
}
if (useDefaultCiphers) {
sslContextBuilder.ciphers(null);
}
sslContext = sslContextBuilder.build();
}
builder.sslContext(sslContext);
} else {
builder.negotiationType(NegotiationType.PLAINTEXT);
}
DefaultThreadFactory tf = new DefaultThreadFactory("client-elg-", true);
switch(transport) {
case NETTY_NIO:
builder.eventLoopGroup(new NioEventLoopGroup(0, tf)).channelType(NioSocketChannel.class);
break;
case NETTY_EPOLL:
// These classes only work on Linux.
builder.eventLoopGroup(new EpollEventLoopGroup(0, tf)).channelType(EpollSocketChannel.class);
break;
case NETTY_UNIX_DOMAIN_SOCKET:
// These classes only work on Linux.
builder.eventLoopGroup(new EpollEventLoopGroup(0, tf)).channelType(EpollDomainSocketChannel.class);
break;
default:
// Should never get here.
throw new IllegalArgumentException("Unsupported transport: " + transport);
}
return builder;
}
use of io.netty.channel.epoll.EpollEventLoopGroup in project pulsar by yahoo.
the class PulsarClientImpl method getEventLoopGroup.
private static EventLoopGroup getEventLoopGroup(ClientConfiguration conf) {
int numThreads = conf.getIoThreads();
ThreadFactory threadFactory = new DefaultThreadFactory("pulsar-client-io");
if (SystemUtils.IS_OS_LINUX) {
try {
return new EpollEventLoopGroup(numThreads, threadFactory);
} catch (ExceptionInInitializerError | NoClassDefFoundError | UnsatisfiedLinkError e) {
if (log.isDebugEnabled()) {
log.debug("Unable to load EpollEventLoop", e);
}
return new NioEventLoopGroup(numThreads, threadFactory);
}
} else {
return new NioEventLoopGroup(numThreads, threadFactory);
}
}
Aggregations