Class DisruptorUtil


  • final class DisruptorUtil
    extends java.lang.Object
    Utility methods for getting Disruptor related configuration.
    • Field Detail

      • LOGGER

        private static final Logger LOGGER
      • RINGBUFFER_DEFAULT_SIZE

        private static final int RINGBUFFER_DEFAULT_SIZE
        See Also:
        Constant Field Values
      • RINGBUFFER_NO_GC_DEFAULT_SIZE

        private static final int RINGBUFFER_NO_GC_DEFAULT_SIZE
        See Also:
        Constant Field Values
      • ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL

        static final boolean ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL
        LOG4J2-2606: Users encountered excessive CPU utilization with Disruptor v3.4.2 when the application was logging more than the underlying appender could keep up with and the ringbuffer became full, especially when the number of application threads vastly outnumbered the number of cores. CPU utilization is significantly reduced by restricting access to the enqueue operation.
      • ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL

        static final boolean ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL
    • Constructor Detail

      • DisruptorUtil

        private DisruptorUtil()
    • Method Detail

      • createWaitStrategy

        static com.lmax.disruptor.WaitStrategy createWaitStrategy​(java.lang.String propertyName,
                                                                  AsyncWaitStrategyFactory asyncWaitStrategyFactory)
      • calculateRingBufferSize

        static int calculateRingBufferSize​(java.lang.String propertyName)
      • getAsyncLoggerExceptionHandler

        static com.lmax.disruptor.ExceptionHandler<RingBufferLogEvent> getAsyncLoggerExceptionHandler()
      • getExecutorThreadId

        public static long getExecutorThreadId​(java.util.concurrent.ExecutorService executor)
        Returns the thread ID of the background appender thread. This allows us to detect Logger.log() calls initiated from the appender thread, which may cause deadlock when the RingBuffer is full. (LOG4J2-471)
        Parameters:
        executor - runs the appender thread
        Returns:
        the thread ID of the background appender thread