K - the type of the conflation keyV - the type of values in the queue@FunctionalInterface public interface AppenderListener<K,V>
appender of a ConflationQueue for instance useful to
record performance metrics related to enqueue operations. The listener or a supplier thereof is usually passed to
the constructor of a conflation queue. Note that listeners must be thread safe if used in a multi-producer
environment; best practice is to use separate listener instances for each producer thread e.g. by using
threadLocal(Supplier) or threadLocalSupplier(Supplier).| Modifier and Type | Interface and Description |
|---|---|
static class |
AppenderListener.Conflation
The type of conflation that occurred when an element was enqueued.
|
| Modifier and Type | Field and Description |
|---|---|
static AppenderListener<java.lang.Object,java.lang.Object> |
NOOP
Constant for a no-op listener.
|
| Modifier and Type | Method and Description |
|---|---|
void |
enqueued(ConflationQueue<? extends K,? extends V> queue,
K key,
V newValue,
V oldValue,
AppenderListener.Conflation conflation)
Called whenever a value is
enqueued. |
static <K,V> AppenderListener<K,V> |
threadLocal(java.util.function.Supplier<? extends AppenderListener<K,V>> listenerSupplier)
Creates an appender listener that delegates to thread-local listener instances created on demand by the given
supplier.
|
static <L extends AppenderListener<?,?>> |
threadLocalSupplier(java.util.function.Supplier<L> listenerSupplier)
Creates a thread local supplier that creates a new instance once for every caller thread.
|
static final AppenderListener<java.lang.Object,java.lang.Object> NOOP
void enqueued(ConflationQueue<? extends K,? extends V> queue, K key, V newValue, V oldValue, AppenderListener.Conflation conflation)
enqueued.queue - the conflation queue, sometimes useful to record queue size metrics, never nullkey - the conflation key, never nullnewValue - the value that has been enqueued (the merged value if conflation==MERGED), never nulloldValue - the old value that is replaced, unless conflation=UNCONFLATED in which case old value is
either null or the exchange value in case of an ExchangeConflationQueueconflation - the type of conflation that has occurred, if anystatic <K,V> AppenderListener<K,V> threadLocal(java.util.function.Supplier<? extends AppenderListener<K,V>> listenerSupplier)
AtomicConflationQueue which use a single
appender instance for all producer threads.K - the type of the conflation keyV - the type of values in the queuelistenerSupplier - the supplier acting as factory for per-thread listener instancesstatic <L extends AppenderListener<?,?>> java.util.function.Supplier<L> threadLocalSupplier(java.util.function.Supplier<L> listenerSupplier)
EvictConflationQueue and MergeConflationQueue which use a per
thread appender instances; the returned supplier will create a new thread-local listener instance for every
appender instance that is created.L - the appender listener (sub-)typelistenerSupplier - the supplier acting as factory for per-thread listener instances