Class NettyUtils

java.lang.Object
org.ldaptive.transport.netty.NettyUtils

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

    Fields
    Modifier and Type
    Field
    Description
    private 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
    Modifier
    Constructor
    Description
    private
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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)
    Invokes EventExecutorGroup.shutdownGracefully(long, long, TimeUnit) on the supplied worker group.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_SHUTDOWN_QUIET_PERIOD

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

      private static final long DEFAULT_SHUTDOWN_MAX_TIMEOUT
      Time in milliseconds for graceful shutdown max wait.
      See Also:
    • 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 org.slf4j.Logger LOGGER
      Logger for this class.
  • Constructor Details

    • NettyUtils

      private NettyUtils()
      Default constructor.
  • Method Details

    • 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