@ThreadSafe public final class NettyUtils extends Object
Modifier and Type | Field and Description |
---|---|
static ChannelType |
USER_CHANNEL_TYPE |
static ChannelType |
WORKER_CHANNEL_TYPE |
Modifier and Type | Method and Description |
---|---|
static io.netty.channel.EventLoopGroup |
createEventLoop(ChannelType type,
int numThreads,
String threadPrefix,
boolean isDaemon)
Creates a Netty
EventLoopGroup based on ChannelType . |
static void |
disableAutoRead(io.netty.channel.Channel channel)
Disables auto read for a netty channel.
|
static void |
enableAutoRead(io.netty.channel.Channel channel)
Enables auto read for a netty channel.
|
static Class<? extends io.netty.channel.Channel> |
getClientChannelClass(boolean isDomainSocket)
Returns the correct
SocketChannel class for use by the client. |
static Class<? extends io.netty.channel.ServerChannel> |
getServerChannelClass(boolean isDomainSocket)
Returns the correct
ServerSocketChannel class for use by the
worker. |
static boolean |
isDomainSocketSupported(WorkerNetAddress workerNetAddress) |
public static final ChannelType USER_CHANNEL_TYPE
public static final ChannelType WORKER_CHANNEL_TYPE
public static io.netty.channel.EventLoopGroup createEventLoop(ChannelType type, int numThreads, String threadPrefix, boolean isDaemon)
EventLoopGroup
based on ChannelType
.type
- Selector for which form of low-level IO we should usenumThreads
- target number of threadsthreadPrefix
- name pattern for each thread. should contain '%d' to distinguish between
threads.isDaemon
- if true, the ThreadFactory
will create daemon
threads.public static Class<? extends io.netty.channel.ServerChannel> getServerChannelClass(boolean isDomainSocket)
ServerSocketChannel
class for use by the
worker.isDomainSocket
- whether this is a domain socket serverpublic static Class<? extends io.netty.channel.Channel> getClientChannelClass(boolean isDomainSocket)
SocketChannel
class for use by the client.isDomainSocket
- whether this is to connect to a domain socket serverpublic static void enableAutoRead(io.netty.channel.Channel channel)
channel
- the netty channelpublic static void disableAutoRead(io.netty.channel.Channel channel)
channel
- the netty channelpublic static boolean isDomainSocketSupported(WorkerNetAddress workerNetAddress)
workerNetAddress
- the worker addressCopyright © 2023. All Rights Reserved.