Class DisruptorUtil
- java.lang.Object
-
- org.apache.logging.log4j.core.async.DisruptorUtil
-
final class DisruptorUtil extends java.lang.Object
Utility methods for getting Disruptor related configuration.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static boolean
ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL
(package private) static 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.private static Logger
LOGGER
private static int
RINGBUFFER_DEFAULT_SIZE
private static int
RINGBUFFER_MIN_SIZE
private static int
RINGBUFFER_NO_GC_DEFAULT_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description private
DisruptorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static int
calculateRingBufferSize(java.lang.String propertyName)
(package private) static com.lmax.disruptor.WaitStrategy
createWaitStrategy(java.lang.String propertyName)
(package private) static com.lmax.disruptor.ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper>
getAsyncLoggerConfigExceptionHandler()
(package private) static com.lmax.disruptor.ExceptionHandler<RingBufferLogEvent>
getAsyncLoggerExceptionHandler()
static long
getExecutorThreadId(java.util.concurrent.ExecutorService executor)
Returns the thread ID of the background appender thread.private static java.lang.String
getFullPropertyKey(java.lang.String strategyKey, java.lang.String additionalKey)
private static long
parseAdditionalLongProperty(java.lang.String propertyName, java.lang.String additionalKey, long defaultValue)
-
-
-
Field Detail
-
LOGGER
private static final Logger LOGGER
-
RINGBUFFER_MIN_SIZE
private static final int RINGBUFFER_MIN_SIZE
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
createWaitStrategy
static com.lmax.disruptor.WaitStrategy createWaitStrategy(java.lang.String propertyName)
-
getFullPropertyKey
private static java.lang.String getFullPropertyKey(java.lang.String strategyKey, java.lang.String additionalKey)
-
parseAdditionalLongProperty
private static long parseAdditionalLongProperty(java.lang.String propertyName, java.lang.String additionalKey, long defaultValue)
-
calculateRingBufferSize
static int calculateRingBufferSize(java.lang.String propertyName)
-
getAsyncLoggerExceptionHandler
static com.lmax.disruptor.ExceptionHandler<RingBufferLogEvent> getAsyncLoggerExceptionHandler()
-
getAsyncLoggerConfigExceptionHandler
static com.lmax.disruptor.ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper> getAsyncLoggerConfigExceptionHandler()
-
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
-
-