@ThreadSafe public final class NettyUtils extends Object
Modifier and Type | Field and Description |
---|---|
static ChannelType |
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> |
getChannelClass(boolean isDomainSocket,
PropertyKey key,
AlluxioConfiguration conf)
Get the proper channel class.
|
static ChannelType |
getChannelType(PropertyKey key,
AlluxioConfiguration conf)
Get the proper channel type.
|
static Class<? extends io.netty.channel.Channel> |
getClientChannelClass(boolean isDomainSocket)
Returns the correct
SocketChannel class based on ChannelType . |
static Class<? extends io.netty.channel.ServerChannel> |
getServerChannelClass(boolean isDomainSocket,
AlluxioConfiguration conf)
Returns the correct
ServerSocketChannel class for use by the
worker. |
static Class<? extends io.netty.channel.ServerChannel> |
getServerChannelClass(ChannelType workerChannelType,
boolean isDomainSocket)
Returns the correct
ServerSocketChannel class for use by the
worker. |
static ChannelType |
getUserChannel(AlluxioConfiguration conf)
Gets the ChannelType properly from the USER_NETWORK_NETTY_CHANNEL property key.
|
static ChannelType |
getWorkerChannel(AlluxioConfiguration conf)
Gets the worker channel properly from the WORKER_NETWORK_NETTY_CHANNEL property key.
|
static boolean |
isDomainSocketAccessible(WorkerNetAddress workerNetAddress,
AlluxioConfiguration conf) |
static boolean |
isDomainSocketSupported(WorkerNetAddress workerNetAddress) |
static boolean |
isNettyEpollAvailable() |
public static final ChannelType 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(ChannelType workerChannelType, boolean isDomainSocket)
ServerSocketChannel
class for use by the
worker.workerChannelType
- worker channel typeisDomainSocket
- whether this is a domain socket serverpublic static Class<? extends io.netty.channel.ServerChannel> getServerChannelClass(boolean isDomainSocket, AlluxioConfiguration conf)
ServerSocketChannel
class for use by the
worker.isDomainSocket
- whether this is a domain socket serverconf
- Alluxio configurationpublic static boolean isDomainSocketAccessible(WorkerNetAddress workerNetAddress, AlluxioConfiguration conf)
workerNetAddress
- the worker addressconf
- Alluxio configurationpublic 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 addresspublic static boolean isNettyEpollAvailable()
public static ChannelType getUserChannel(AlluxioConfiguration conf)
conf
- Alluxio configurationpublic static ChannelType getWorkerChannel(AlluxioConfiguration conf)
conf
- Alluxio configurationpublic static Class<? extends io.netty.channel.Channel> getClientChannelClass(boolean isDomainSocket)
SocketChannel
class based on ChannelType
.isDomainSocket
- whether this is to connect to a domain socket serverpublic static Class<? extends io.netty.channel.Channel> getChannelClass(boolean isDomainSocket, PropertyKey key, AlluxioConfiguration conf)
NioSocketChannel
NIO if EPOLL is not available.isDomainSocket
- whether this is for a domain channelkey
- the property key for looking up the configured channel typeconf
- the Alluxio configurationpublic static ChannelType getChannelType(PropertyKey key, AlluxioConfiguration conf)
ChannelType
NIO if EPOLL is not available.key
- the property key for looking up the configured channel typeconf
- the Alluxio configurationCopyright © 2023. All Rights Reserved.