Class DisruptorUtil

java.lang.Object
org.apache.logging.log4j.core.async.DisruptorUtil

final class DisruptorUtil extends Object
Utility methods for getting Disruptor related configuration.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • RINGBUFFER_MIN_SIZE

      private static final int RINGBUFFER_MIN_SIZE
      See Also:
    • RINGBUFFER_DEFAULT_SIZE

      private static final int RINGBUFFER_DEFAULT_SIZE
      See Also:
    • RINGBUFFER_NO_GC_DEFAULT_SIZE

      private static final int RINGBUFFER_NO_GC_DEFAULT_SIZE
      See Also:
    • 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 Details

    • DisruptorUtil

      private DisruptorUtil()
  • Method Details

    • createWaitStrategy

      static com.lmax.disruptor.WaitStrategy createWaitStrategy(String propertyName)
    • getFullPropertyKey

      private static String getFullPropertyKey(String strategyKey, String additionalKey)
    • parseAdditionalLongProperty

      private static long parseAdditionalLongProperty(String propertyName, String additionalKey, long defaultValue)
    • calculateRingBufferSize

      static int calculateRingBufferSize(String propertyName)
    • getAsyncLoggerExceptionHandler

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

      static com.lmax.disruptor.ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper> getAsyncLoggerConfigExceptionHandler()
    • getExecutorThreadId

      public static long getExecutorThreadId(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