K - the type of the conflation keyV - the type of elements in the queuepublic class MergeConflationQueue<K,V> extends java.lang.Object implements ExchangeConflationQueue<K,V>
Each producer should acquire its own appender from the producing thread, and similarly every
consumer should call poller() from the consuming thread. Note that appender listener and poller listener
must be thread safe if multiple producers or consumers are used, e.g. use
AppenderListener.threadLocalSupplier(Supplier) and PollerListener.threadLocalSupplier(Supplier) to
create separate listener instances per producer/consumer thread.
ExchangeConflationQueue.ExchangePoller<K,V>ConflationQueue.Appender<K,V>, ConflationQueue.Poller<K,V>| Constructor and Description |
|---|
MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger)
Constructor with queue factory and merger.
|
MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger,
java.util.List<? extends K> allConflationKeys)
Constructor with queue factory, merger and the exhaustive list of conflation keys.
|
MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger,
java.util.List<? extends K> allConflationKeys,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Constructor with queue factory, merger and the exhaustive list of conflation keys.
|
MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Constructor with queue factory and merger.
|
| Modifier and Type | Method and Description |
|---|---|
ConflationQueue.Appender<K,V> |
appender()
Returns the appender object used by the producer to enqueue values.
|
static <K extends java.lang.Enum<K>,V> |
forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger,
java.lang.Class<K> conflationKeyClass)
Static constructor method for a conflation queue with queue factory, merger and the conflation key enum class.
|
static <K extends java.lang.Enum<K>,V> |
forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory,
Merger<? super K,V> merger,
java.lang.Class<K> conflationKeyClass,
java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier,
java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
Static constructor method for a conflation queue with queue factory, merger and the conflation key enum class.
|
ExchangeConflationQueue.ExchangePoller<K,V> |
poller()
Returns the poller object used by the consumer to poll values.
|
int |
size()
Returns the number of elements in this queue.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnullSafe, nullSafepublic MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger)
queueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occurspublic MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
queueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occursappenderListenerSupplier - a supplier for a listener to monitor the enqueue operationspollerListenerSupplier - a supplier for a listener to monitor the poll operationspublic MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger, java.util.List<? extends K> allConflationKeys)
queueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occursallConflationKeys - all conflation keys that will ever be used with this conflation queue instancepublic MergeConflationQueue(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger, java.util.List<? extends K> allConflationKeys, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
queueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occursallConflationKeys - all conflation keys that will ever be used with this conflation queue instanceappenderListenerSupplier - a supplier for a listener to monitor the enqueue operationspollerListenerSupplier - a supplier for a listener to monitor the poll operationspublic static <K extends java.lang.Enum<K>,V> MergeConflationQueue<K,V> forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger, java.lang.Class<K> conflationKeyClass)
K - the type of the conflation keyV - the type of elements in the queuequeueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occursconflationKeyClass - the conflation key enum classpublic static <K extends java.lang.Enum<K>,V> MergeConflationQueue<K,V> forEnumConflationKey(java.util.function.Supplier<? extends java.util.Queue<java.lang.Object>> queueFactory, Merger<? super K,V> merger, java.lang.Class<K> conflationKeyClass, java.util.function.Supplier<? extends AppenderListener<? super K,? super V>> appenderListenerSupplier, java.util.function.Supplier<? extends PollerListener<? super K,? super V>> pollerListenerSupplier)
K - the type of the conflation keyV - the type of elements in the queuequeueFactory - the factory to create the backing queuemerger - the merge strategy to use if conflation occursconflationKeyClass - the conflation key enum classappenderListenerSupplier - a supplier for a listener to monitor the enqueue operationspollerListenerSupplier - a supplier for a listener to monitor the poll operationspublic ConflationQueue.Appender<K,V> appender()
ConflationQueueappender in interface ConflationQueue<K,V>appender in interface ExchangeConflationQueue<K,V>public ExchangeConflationQueue.ExchangePoller<K,V> poller()
ConflationQueuepoller in interface ConflationQueue<K,V>poller in interface ExchangeConflationQueue<K,V>public int size()
ConflationQueueBeware that, unlike in most collections, this method may NOT be a constant-time operation. Because of the asynchronous nature of concurrent queues, determining the current number of elements may require an O(n) traversal. Additionally, if elements are added or removed during execution of this method, the returned result may be inaccurate. Thus, this method is typically not very useful in concurrent applications.
size in interface ConflationQueue<K,V>