Merge remote-tracking branch 'origin/dev/3.0.0' into cleanup/plugin-message-channel-handling
This commit is contained in:
@@ -121,6 +121,9 @@ dependencies {
|
||||
implementation(libs.netty.transport.native.epoll)
|
||||
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") })
|
||||
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-aarch_64") })
|
||||
implementation(libs.netty.transport.native.iouring)
|
||||
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-x86_64") })
|
||||
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-aarch_64") })
|
||||
implementation(libs.netty.transport.native.kqueue)
|
||||
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-x86_64") })
|
||||
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-aarch_64") })
|
||||
|
@@ -20,25 +20,32 @@ package com.velocitypowered.proxy.network;
|
||||
import com.velocitypowered.proxy.util.concurrent.VelocityNettyThreadFactory;
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.IoHandlerFactory;
|
||||
import io.netty.channel.MultiThreadIoEventLoopGroup;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollDatagramChannel;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollIoHandler;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.kqueue.KQueue;
|
||||
import io.netty.channel.kqueue.KQueueDatagramChannel;
|
||||
import io.netty.channel.kqueue.KQueueEventLoopGroup;
|
||||
import io.netty.channel.kqueue.KQueueIoHandler;
|
||||
import io.netty.channel.kqueue.KQueueServerSocketChannel;
|
||||
import io.netty.channel.kqueue.KQueueSocketChannel;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.nio.NioIoHandler;
|
||||
import io.netty.channel.socket.DatagramChannel;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.channel.uring.IoUring;
|
||||
import io.netty.channel.uring.IoUringDatagramChannel;
|
||||
import io.netty.channel.uring.IoUringIoHandler;
|
||||
import io.netty.channel.uring.IoUringServerSocketChannel;
|
||||
import io.netty.channel.uring.IoUringSocketChannel;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Enumerates the supported transports for Velocity.
|
||||
@@ -47,32 +54,36 @@ public enum TransportType {
|
||||
NIO("NIO", NioServerSocketChannel::new,
|
||||
NioSocketChannel::new,
|
||||
NioDatagramChannel::new,
|
||||
(name, type) -> new NioEventLoopGroup(0, createThreadFactory(name, type))),
|
||||
NioIoHandler::newFactory),
|
||||
EPOLL("epoll", EpollServerSocketChannel::new,
|
||||
EpollSocketChannel::new,
|
||||
EpollDatagramChannel::new,
|
||||
(name, type) -> new EpollEventLoopGroup(0, createThreadFactory(name, type))),
|
||||
EpollIoHandler::newFactory),
|
||||
KQUEUE("kqueue", KQueueServerSocketChannel::new,
|
||||
KQueueSocketChannel::new,
|
||||
KQueueDatagramChannel::new,
|
||||
(name, type) -> new KQueueEventLoopGroup(0, createThreadFactory(name, type)));
|
||||
KQueueIoHandler::newFactory),
|
||||
IO_URING("io_uring", IoUringServerSocketChannel::new,
|
||||
IoUringSocketChannel::new,
|
||||
IoUringDatagramChannel::new,
|
||||
IoUringIoHandler::newFactory);
|
||||
|
||||
final String name;
|
||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
|
||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
|
||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
|
||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory;
|
||||
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier;
|
||||
|
||||
TransportType(final String name,
|
||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
|
||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
|
||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
|
||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory) {
|
||||
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier) {
|
||||
this.name = name;
|
||||
this.serverSocketChannelFactory = serverSocketChannelFactory;
|
||||
this.socketChannelFactory = socketChannelFactory;
|
||||
this.datagramChannelFactory = datagramChannelFactory;
|
||||
this.eventLoopGroupFactory = eventLoopGroupFactory;
|
||||
this.ioHandlerFactorySupplier = ioHandlerFactorySupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,8 +91,15 @@ public enum TransportType {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new event loop group for the given type.
|
||||
*
|
||||
* @param type the type of event loop group to create
|
||||
* @return the event loop group
|
||||
*/
|
||||
public EventLoopGroup createEventLoopGroup(final Type type) {
|
||||
return this.eventLoopGroupFactory.apply(this.name, type);
|
||||
return new MultiThreadIoEventLoopGroup(
|
||||
0, createThreadFactory(this.name, type), this.ioHandlerFactorySupplier.get());
|
||||
}
|
||||
|
||||
private static ThreadFactory createThreadFactory(final String name, final Type type) {
|
||||
@@ -98,6 +116,10 @@ public enum TransportType {
|
||||
return NIO;
|
||||
}
|
||||
|
||||
if (IoUring.isAvailable() && !Boolean.getBoolean("velocity.disable-iouring-transport")) {
|
||||
return IO_URING;
|
||||
}
|
||||
|
||||
if (Epoll.isAvailable()) {
|
||||
return EPOLL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user