public class ConcurrentBoundedPriorityIterable<T> extends Object implements Iterable<AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T>>
Iterable. Given a ResourcePool, a ResourceEstimator, and a
Comparator as a prioritizer, user can attempt to add elements to this container.
The container stores a subset of the offered elements such that their ResourceRequirement is within the
bounds of the ResourcePool, preferentially storing high priority elements.
This functionality is achieved by automatic eviction of low priority items when space for a higher priority item
is needed.
A call to iterator() returns an iterator over the current elements in the container in order from high
priority to low priority. Note after calling iterator(), no more requests can be added (will throw
RuntimeException).
Note: as with a priority queue, e1 < e2 means that e1 is higher priority than e2.| Constructor and Description |
|---|
ConcurrentBoundedPriorityIterable(Comparator<? super T> prioritizer,
ResourceEstimator<T> resourceEstimator,
String storeRejectedRequestsSetting,
ResourcePool pool) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T t)
Offer an element to the container.
|
boolean |
hasRejectedElement() |
boolean |
isFull() |
Iterator<AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T>> |
iterator() |
void |
logStatistics(com.google.common.base.Optional<org.slf4j.Logger> logger)
Log statistics about this
ConcurrentBoundedPriorityIterable. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic ConcurrentBoundedPriorityIterable(Comparator<? super T> prioritizer, ResourceEstimator<T> resourceEstimator, String storeRejectedRequestsSetting, ResourcePool pool)
public boolean add(T t)
public boolean hasRejectedElement()
add(T) have returned false, i.e. some element has been rejected due
to strict capacity issues.public boolean isFull()
public void logStatistics(com.google.common.base.Optional<org.slf4j.Logger> logger)
ConcurrentBoundedPriorityIterable.public Iterator<AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T>> iterator()
iterator in interface Iterable<AllocatedRequestsIteratorBase.RequestWithResourceRequirement<T>>