use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollEventLoopGroup in project flink by apache.
the class NettyServer method initEpollBootstrap.
private void initEpollBootstrap() {
// Add the server port number to the name in order to distinguish
// multiple servers running on the same host.
String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";
EpollEventLoopGroup epollGroup = new EpollEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name));
bootstrap.group(epollGroup).channel(EpollServerSocketChannel.class);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollEventLoopGroup in project blade by biezhi.
the class EpollKit method group.
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();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.epoll.EpollEventLoopGroup in project herddb by diennea.
the class NettyChannelAcceptor method start.
public void start() throws Exception {
if (ssl) {
if (sslCertFile == null) {
LOGGER.log(Level.INFO, "start SSL with self-signed auto-generated certificate");
if (sslCiphers != null) {
LOGGER.log(Level.INFO, "required sslCiphers " + sslCiphers);
}
SelfSignedCertificate ssc = new SelfSignedCertificate();
try {
sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).ciphers(sslCiphers).build();
} finally {
ssc.delete();
}
} else {
LOGGER.log(Level.INFO, "start SSL with certificate " + sslCertFile.getAbsolutePath() + " chain file " + sslCertChainFile.getAbsolutePath());
if (sslCiphers != null) {
LOGGER.log(Level.INFO, "required sslCiphers " + sslCiphers);
}
sslCtx = SslContextBuilder.forServer(sslCertChainFile, sslCertFile, sslCertPassword).ciphers(sslCiphers).build();
}
}
if (callbackThreads == 0) {
callbackExecutorQueue = new SynchronousQueue<Runnable>();
callbackExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, callbackExecutorQueue, threadFactory);
} else {
callbackExecutorQueue = new LinkedBlockingQueue<Runnable>();
callbackExecutor = new ThreadPoolExecutor(callbackThreads, callbackThreads, 0L, TimeUnit.MILLISECONDS, callbackExecutorQueue, threadFactory);
}
statsLogger.registerGauge("callbacksqueue", new Gauge<Integer>() {
@Override
public Integer getDefaultValue() {
return 0;
}
@Override
public Integer getSample() {
return callbackExecutorQueue.size();
}
});
InetSocketAddress address = new InetSocketAddress(host, port);
if (enableRealNetwork) {
LOGGER.log(Level.INFO, "Starting HerdDB network server at {0}:{1}", new Object[] { host, port + "" });
}
if (enableRealNetwork && address.isUnresolved()) {
throw new IOException("Bind address " + host + ":" + port + " cannot be resolved");
}
ChannelInitializer<io.netty.channel.Channel> channelInitialized = new ChannelInitializer<io.netty.channel.Channel>() {
@Override
public void initChannel(io.netty.channel.Channel ch) throws Exception {
NettyChannel session = new NettyChannel("unnamed", ch, callbackExecutor);
if (acceptor != null) {
acceptor.createConnection(session);
}
// Add SSL handler first to encrypt and decrypt everything.
if (ssl) {
ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()));
}
ch.pipeline().addLast("lengthprepender", new LengthFieldPrepender(4));
ch.pipeline().addLast("lengthbaseddecoder", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
//
ch.pipeline().addLast("messagedecoder", new ProtocolMessageDecoder());
ch.pipeline().addLast(new ServerInboundMessageHandler(session));
}
};
if (enableRealNetwork) {
if (NetworkUtils.isEnableEpoolNative()) {
bossGroup = new EpollEventLoopGroup(workerThreads);
workerGroup = new EpollEventLoopGroup(workerThreads);
LOGGER.log(Level.FINE, "Using netty-native-epoll network type");
} else {
bossGroup = new NioEventLoopGroup(workerThreads);
workerGroup = new NioEventLoopGroup(workerThreads);
LOGGER.log(Level.FINE, "Using nio network type");
}
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NetworkUtils.isEnableEpoolNative() ? EpollServerSocketChannel.class : NioServerSocketChannel.class).childHandler(channelInitialized).option(ChannelOption.SO_BACKLOG, 128);
ChannelFuture f = b.bind(address).sync();
this.channel = f.channel();
}
if (enableJVMNetwork) {
jvmhostAddress = NetworkUtils.getAddress(address);
LocalServerRegistry.registerLocalServer(jvmhostAddress, port, localVMChannelAcceptor);
}
}
Aggregations