Class NettyUtils


  • final class NettyUtils
    extends Object
    Provides utility methods for this package.
    • Field Detail

      • DEFAULT_SHUTDOWN_QUIET_PERIOD

        private static final long DEFAULT_SHUTDOWN_QUIET_PERIOD
        Time in milliseconds for graceful shutdown quiet period.
        See Also:
        Constant Field Values
      • DEFAULT_SHUTDOWN_MAX_TIMEOUT

        private static final long DEFAULT_SHUTDOWN_MAX_TIMEOUT
        Time in milliseconds for graceful shutdown max wait.
        See Also:
        Constant Field Values
      • USE_NIO

        private static final boolean USE_NIO
        Whether to use NIO even if other transports are available.
      • EPOLL_AVAILABLE

        private static final boolean EPOLL_AVAILABLE
        Whether Epoll is available.
      • KQUEUE_AVAILABLE

        private static final boolean KQUEUE_AVAILABLE
        Whether KQueue is available.
      • LOGGER

        private static final Logger LOGGER
        Logger for this class.
    • Constructor Detail

      • NettyUtils

        private NettyUtils()
        Default constructor.
    • Method Detail

      • getDefaultSocketChannelType

        public static Class<? extends io.netty.channel.Channel> getDefaultSocketChannelType()
        Returns the default socket channel type for this platform. See Epoll.isAvailable() and KQueue.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. See Epoll.isAvailable() and KQueue.isAvailable(). Set numThreads to zero to use the netty default.
        Parameters:
        name - of the thread pool
        numThreads - number of threads in the thread pool
        Returns:
        event loop group
      • shutdownGracefully

        public static void shutdownGracefully​(io.netty.channel.EventLoopGroup workerGroup)
        Invokes EventExecutorGroup.shutdownGracefully(long, long, TimeUnit) on the supplied worker group. This method blocks for twice the DEFAULT_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