Class DisruptorUtil
java.lang.Object
org.apache.logging.log4j.core.async.DisruptorUtil
Utility methods for getting Disruptor related configuration.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final boolean
(package private) static final boolean
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.private static final Logger
private static final int
private static final int
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static int
calculateRingBufferSize
(String propertyName) (package private) static com.lmax.disruptor.WaitStrategy
createWaitStrategy
(String propertyName) (package private) static com.lmax.disruptor.ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper>
(package private) static com.lmax.disruptor.ExceptionHandler<RingBufferLogEvent>
static long
getExecutorThreadId
(ExecutorService executor) Returns the thread ID of the background appender thread.private static String
getFullPropertyKey
(String strategyKey, String additionalKey) private static long
parseAdditionalLongProperty
(String propertyName, String additionalKey, long defaultValue)
-
Field Details
-
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_FULLLOG4J2-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
-
getFullPropertyKey
-
parseAdditionalLongProperty
-
calculateRingBufferSize
-
getAsyncLoggerExceptionHandler
-
getAsyncLoggerConfigExceptionHandler
static com.lmax.disruptor.ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper> getAsyncLoggerConfigExceptionHandler() -
getExecutorThreadId
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
-