Package org.ldaptive.transport.netty
Class NettyUtils
java.lang.Object
org.ldaptive.transport.netty.NettyUtils
Provides utility methods for this package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Time in milliseconds for graceful shutdown max wait.private static final long
Time in milliseconds for graceful shutdown quiet period.private static final boolean
Whether Epoll is available.private static final boolean
Whether KQueue is available.private static final org.slf4j.Logger
Logger for this class.private static final boolean
Whether to use NIO even if other transports are available. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.channel.EventLoopGroup
createDefaultEventLoopGroup
(String name, int numThreads) Returns the default event loop group for this platform.static Class<? extends io.netty.channel.Channel>
Returns the default socket channel type for this platform.static void
shutdownGracefully
(io.netty.channel.EventLoopGroup workerGroup) InvokesEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
on the supplied worker group.
-
Field Details
-
DEFAULT_SHUTDOWN_QUIET_PERIOD
private static final long DEFAULT_SHUTDOWN_QUIET_PERIODTime in milliseconds for graceful shutdown quiet period.- See Also:
-
DEFAULT_SHUTDOWN_MAX_TIMEOUT
private static final long DEFAULT_SHUTDOWN_MAX_TIMEOUTTime in milliseconds for graceful shutdown max wait.- See Also:
-
USE_NIO
private static final boolean USE_NIOWhether to use NIO even if other transports are available. -
EPOLL_AVAILABLE
private static final boolean EPOLL_AVAILABLEWhether Epoll is available. -
KQUEUE_AVAILABLE
private static final boolean KQUEUE_AVAILABLEWhether KQueue is available. -
LOGGER
private static final org.slf4j.Logger LOGGERLogger for this class.
-
-
Constructor Details
-
NettyUtils
private NettyUtils()Default constructor.
-
-
Method Details
-
getDefaultSocketChannelType
Returns the default socket channel type for this platform. SeeEpoll.isAvailable()
andKQueue.isAvailable()
.- Returns:
- socket channel type
-
createDefaultEventLoopGroup
public static io.netty.channel.EventLoopGroup createDefaultEventLoopGroup(String name, int numThreads) Returns the default event loop group for this platform. SeeEpoll.isAvailable()
andKQueue.isAvailable()
. Set numThreads to zero to use the netty default.- Parameters:
name
- of the thread poolnumThreads
- number of threads in the thread pool- Returns:
- event loop group
-
shutdownGracefully
public static void shutdownGracefully(io.netty.channel.EventLoopGroup workerGroup) InvokesEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)
on the supplied worker group. This method blocks for twice theDEFAULT_SHUTDOWN_MAX_TIMEOUT
waiting for the shutdown to be done. If the future is not invoked in that timeframe a warning is logged.- Parameters:
workerGroup
- to shutdown
-