@Private
public class ValueQueue<E>
extends java.lang.Object
numValues entries
available for the client to consume for a particular key.
It also uses an underlying Cache to evict queues for keys that have not been
accessed for a configurable period of time.
Implementing classes are required to implement the
QueueRefiller interface that exposes a method to refill the
queue, when empty| Modifier and Type | Class | Description |
|---|---|---|
static interface |
ValueQueue.QueueRefiller<E> |
QueueRefiller interface a client must implement to use this class
|
static class |
ValueQueue.SyncGenerationPolicy |
Policy to decide how many values to return to client when client asks for
"n" values and Queue is empty.
|
| Constructor | Description |
|---|---|
ValueQueue(int numValues,
float lowWaterMark,
long expiry,
int numFillerThreads,
ValueQueue.QueueRefiller<E> fetcher) |
|
ValueQueue(int numValues,
float lowWatermark,
long expiry,
int numFillerThreads,
ValueQueue.SyncGenerationPolicy policy,
ValueQueue.QueueRefiller<E> refiller) |
Constructor takes the following tunable configuration parameters
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
drain(java.lang.String keyName) |
Drains the Queue for the provided key.
|
java.util.List<E> |
getAtMost(java.lang.String keyName,
int num) |
This removes the "num" values currently at the head of the Queue for the
provided key.
|
E |
getNext(java.lang.String keyName) |
This removes the value currently at the head of the Queue for the
provided key.
|
int |
getSize(java.lang.String keyName) |
Get size of the Queue for keyName.
|
void |
initializeQueuesForKeys(java.lang.String... keyNames) |
Initializes the Value Queues for the provided keys by calling the
fill Method with "numInitValues" values
|
void |
shutdown() |
Cleanly shutdown
|
public ValueQueue(int numValues,
float lowWatermark,
long expiry,
int numFillerThreads,
ValueQueue.SyncGenerationPolicy policy,
ValueQueue.QueueRefiller<E> refiller)
numValues - The number of values cached in the Queue for a
particular key.lowWatermark - The ratio of (number of current entries/numValues)
below which the fillQueueForKey() funciton will be
invoked to fill the Queue.expiry - Expiry time after which the Key and associated Queue are
evicted from the cache.numFillerThreads - Number of threads to use for the filler threadpolicy - The SyncGenerationPolicy to use when client
calls "getAtMost"refiller - implementation of the QueueRefillerpublic ValueQueue(int numValues,
float lowWaterMark,
long expiry,
int numFillerThreads,
ValueQueue.QueueRefiller<E> fetcher)
public void initializeQueuesForKeys(java.lang.String... keyNames)
throws java.util.concurrent.ExecutionException
keyNames - Array of key Namesjava.util.concurrent.ExecutionException - executionException.public E getNext(java.lang.String keyName) throws java.io.IOException, java.util.concurrent.ExecutionException
keyName - String key namejava.io.IOException - raised on errors performing I/O.java.util.concurrent.ExecutionException - executionException.public void drain(java.lang.String keyName)
keyName - the key to drain the Queue for@VisibleForTesting public int getSize(java.lang.String keyName)
keyName - the key namepublic java.util.List<E> getAtMost(java.lang.String keyName, int num) throws java.io.IOException, java.util.concurrent.ExecutionException
SyncGenerationPolicy specified by the user.keyName - String key namenum - Minimum number of values to return.java.io.IOException - raised on errors performing I/O.java.util.concurrent.ExecutionException - execution exception.public void shutdown()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.