Class AsyncHandler
java.lang.Object
java.util.logging.Handler
org.jboss.logmanager.ExtHandler
org.jboss.logmanager.handlers.AsyncHandler
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, FlushableCloseable, Protectable
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 ClassesModifier and TypeClassDescriptionprivate final classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate AsyncHandler.OverflowActionprivate final intprivate final BlockingQueue<ExtLogRecord> private intprivate static final AtomicIntegerFieldUpdater<AsyncHandler> private final ThreadFields inherited from class ExtHandler
handlers, handlersUpdater -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance.AsyncHandler(int queueLength) Construct a new instance.AsyncHandler(int queueLength, ThreadFactory threadFactory) Construct a new instance.AsyncHandler(ThreadFactory threadFactory) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close all child handlers.protected voiddoPublish(ExtLogRecord record) Do the actual work of publication; the record will have been filtered already.Get the overflow action.intThe full size of the queue.voidsetOverflowAction(AsyncHandler.OverflowAction overflowAction) Set the overflow action.Methods inherited from class ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, flush, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotectMethods inherited from class Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError
-
Field Details
-
recordQueue
-
queueLength
private final int queueLength -
thread
-
overflowAction
-
state
private volatile int state -
stateUpdater
-
DEFAULT_QUEUE_LENGTH
private static final int DEFAULT_QUEUE_LENGTH- See Also:
-
-
Constructor Details
-
AsyncHandler
Construct a new instance.- Parameters:
queueLength- the queue lengththreadFactory- the thread factory to use to construct the handler thread
-
AsyncHandler
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 Details
-
getQueueLength
public int getQueueLength()The full size of the queue.- Returns:
- the full size of the queue.
-
getOverflowAction
Get the overflow action.- Returns:
- the overflow action
-
setOverflowAction
Set the overflow action.- Parameters:
overflowAction- the overflow action
-
doPublish
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
Close all child handlers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classExtHandler- Throws:
SecurityException
-