@ThreadSafe public class TopicPartitionHistoryPool<H extends TopicPartitionHistory> extends Object
TopicPartitionHistory
s. It allows adding new TopicPartitionHistory
s or
updating existing ones with new expiration deadlines. It also provides a blocking take method to retrieve the expired
TopicPartitionHistory
s.Constructor and Description |
---|
TopicPartitionHistoryPool() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(H history)
Adds a new
TopicPartitionHistory to the pool. |
long |
epoch()
Retrieves current epoch.
|
boolean |
isEmpty()
Returns true if the pool contains no elements.
|
void |
newEpoch(long newEpoch)
Update the epoch and unblock waiting threads.
|
H |
takeExpired()
Retrieves and removes one expired
TopicPartitionHistory , waiting if necessary until an element with an
expired delay is available. |
boolean |
update(H history)
Adds a new
TopicPartitionHistory to the pool. |
public boolean add(H history)
TopicPartitionHistory
to the pool.history
- new history to be addedpublic boolean update(H history)
TopicPartitionHistory
to the pool. If a previous history of the same topic partition exists,
update the entry if the new history has a later deadline.history
- new history to be addedpublic H takeExpired() throws InterruptedException
TopicPartitionHistory
, waiting if necessary until an element with an
expired delay is available.TopicPartitionHistory
InterruptedException
- if interrupted while waitingpublic long epoch()
public void newEpoch(long newEpoch)
public boolean isEmpty()