class AsyncLoggerDisruptor extends AbstractLifeCycle
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
private AsyncQueueFullPolicy |
asyncQueueFullPolicy |
private long |
backgroundThreadId |
private java.lang.String |
contextName |
private com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> |
disruptor |
private java.util.concurrent.ExecutorService |
executor |
private static int |
MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN |
private int |
ringBufferSize |
private static int |
SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS |
private boolean |
useThreadLocalTranslator |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Constructor and Description |
---|
AsyncLoggerDisruptor(java.lang.String contextName) |
Modifier and Type | Method and Description |
---|---|
RingBufferAdmin |
createRingBufferAdmin(java.lang.String jmxContextName)
Creates and returns a new
RingBufferAdmin that instruments the ringbuffer of the AsyncLogger . |
(package private) void |
enqueueLogMessageInfo(RingBufferLogEventTranslator translator) |
java.lang.String |
getContextName() |
(package private) com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> |
getDisruptor() |
(package private) EventRoute |
getEventRoute(Level logLevel) |
private static boolean |
hasBacklog(com.lmax.disruptor.dsl.Disruptor<?> theDisruptor)
Returns
true if the specified disruptor still has unprocessed events. |
private boolean |
hasLog4jBeenShutDown(com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> aDisruptor)
Returns
true if the specified disruptor is null. |
boolean |
isUseThreadLocals()
Returns whether it is allowed to store non-JDK classes in ThreadLocal objects for efficiency.
|
private int |
remainingDisruptorCapacity() |
void |
setContextName(java.lang.String name) |
void |
setUseThreadLocals(boolean allow)
Signals this AsyncLoggerDisruptor whether it is allowed to store non-JDK classes in ThreadLocal objects for
efficiency.
|
void |
start()
Creates and starts a new Disruptor and associated thread if none currently exists.
|
boolean |
stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Decreases the reference count.
|
boolean |
tryPublish(RingBufferLogEventTranslator translator) |
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
private static final int SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS
private static final int MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN
private volatile com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> disruptor
private java.util.concurrent.ExecutorService executor
private java.lang.String contextName
private boolean useThreadLocalTranslator
private long backgroundThreadId
private AsyncQueueFullPolicy asyncQueueFullPolicy
private int ringBufferSize
public java.lang.String getContextName()
public void setContextName(java.lang.String name)
com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> getDisruptor()
public void start()
start
in interface LifeCycle
start
in class AbstractLifeCycle
AbstractLifeCycle.stop()
public boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
null
.stop
in interface LifeCycle2
stop
in class AbstractLifeCycle
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumentprivate static boolean hasBacklog(com.lmax.disruptor.dsl.Disruptor<?> theDisruptor)
true
if the specified disruptor still has unprocessed events.public RingBufferAdmin createRingBufferAdmin(java.lang.String jmxContextName)
RingBufferAdmin
that instruments the ringbuffer of the AsyncLogger
.jmxContextName
- name of the AsyncLoggerContext
RingBufferAdmin
that instruments the ringbufferEventRoute getEventRoute(Level logLevel)
private int remainingDisruptorCapacity()
private boolean hasLog4jBeenShutDown(com.lmax.disruptor.dsl.Disruptor<RingBufferLogEvent> aDisruptor)
true
if the specified disruptor is null.public boolean tryPublish(RingBufferLogEventTranslator translator)
void enqueueLogMessageInfo(RingBufferLogEventTranslator translator)
public boolean isUseThreadLocals()
public void setUseThreadLocals(boolean allow)
This property may be modified after the start()
method has been called.
allow
- whether AsyncLoggers are allowed to use ThreadLocal objects