Package org.jboss.logmanager.handlers
Class AsyncHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- org.jboss.logmanager.ExtHandler
-
- org.jboss.logmanager.handlers.AsyncHandler
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,FlushableCloseable,Protectable
public class AsyncHandler extends ExtHandler
An asynchronous log handler which is used to write to a handler or group of handlers which are "slow" or introduce some degree of latency.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAsyncHandler.AsyncTaskstatic classAsyncHandler.OverflowAction
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_QUEUE_LENGTHprivate AsyncHandler.OverflowActionoverflowActionprivate intqueueLengthprivate java.util.concurrent.BlockingQueue<ExtLogRecord>recordQueueprivate intstateprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AsyncHandler>stateUpdaterprivate java.lang.Threadthread-
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
-
-
Constructor Summary
Constructors Constructor Description AsyncHandler()Construct a new instance.AsyncHandler(int queueLength)Construct a new instance.AsyncHandler(int queueLength, java.util.concurrent.ThreadFactory threadFactory)Construct a new instance.AsyncHandler(java.util.concurrent.ThreadFactory threadFactory)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close all child handlers.protected voiddoPublish(ExtLogRecord record)Do the actual work of publication; the record will have been filtered already.AsyncHandler.OverflowActiongetOverflowAction()Get the overflow action.intgetQueueLength()The full size of the queue.voidsetOverflowAction(AsyncHandler.OverflowAction overflowAction)Set the overflow action.-
Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, flush, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect
-
-
-
-
Field Detail
-
recordQueue
private final java.util.concurrent.BlockingQueue<ExtLogRecord> recordQueue
-
queueLength
private final int queueLength
-
thread
private final java.lang.Thread thread
-
overflowAction
private volatile AsyncHandler.OverflowAction overflowAction
-
state
private volatile int state
-
stateUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AsyncHandler> stateUpdater
-
DEFAULT_QUEUE_LENGTH
private static final int DEFAULT_QUEUE_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AsyncHandler
public AsyncHandler(int queueLength, java.util.concurrent.ThreadFactory threadFactory)Construct a new instance.- Parameters:
queueLength- the queue lengththreadFactory- the thread factory to use to construct the handler thread
-
AsyncHandler
public AsyncHandler(java.util.concurrent.ThreadFactory threadFactory)
Construct a new instance.- Parameters:
threadFactory- the thread factory to use to construct the handler thread
-
AsyncHandler
public AsyncHandler(int queueLength)
Construct a new instance.- Parameters:
queueLength- the queue length
-
AsyncHandler
public AsyncHandler()
Construct a new instance.
-
-
Method Detail
-
getQueueLength
public int getQueueLength()
The full size of the queue.- Returns:
- the full size of the queue.
-
getOverflowAction
public AsyncHandler.OverflowAction getOverflowAction()
Get the overflow action.- Returns:
- the overflow action
-
setOverflowAction
public void setOverflowAction(AsyncHandler.OverflowAction overflowAction)
Set the overflow action.- Parameters:
overflowAction- the overflow action
-
doPublish
protected void doPublish(ExtLogRecord record)
Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if theautoFlushproperty is set totrue; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.- Overrides:
doPublishin classExtHandler- Parameters:
record- the log record to publish
-
close
public void close() throws java.lang.SecurityExceptionClose all child handlers.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classExtHandler- Throws:
java.lang.SecurityException
-
-