public interface TopicPartitionHistory extends Comparable<TopicPartitionHistory>
TopicPartition
.Modifier and Type | Method and Description |
---|---|
default int |
compareTo(TopicPartitionHistory that)
Each
TopicPartitionHistory is a comparable object, representing a certain history fact of a
TopicPartition . |
long |
deadlineMs()
Retrieves the deadline after which the history item expires.
|
long |
epoch()
Retrieves the epoch of the history item.
|
org.apache.kafka.common.TopicPartition |
topicPartition()
Retrieves the topic partition associated with this history item.
|
long |
untilDeadline(TimeUnit unit)
Retrieves the remaining time duration until the history item expires with the given
TimeUnit . |
org.apache.kafka.common.TopicPartition topicPartition()
long epoch()
long deadlineMs()
long untilDeadline(TimeUnit unit)
TimeUnit
.default int compareTo(TopicPartitionHistory that)
TopicPartitionHistory
is a comparable object, representing a certain history fact of a
TopicPartition
.
When comparing TopicPartitionHistory
:
1. Their epochs are first evaluated and the one with bigger epoch is considered larger.
2. If both have the same epoch, the one with later expiration deadline is considered larger.
3. If both have the same epoch AND the same expiration deadline, then the tie is broken by comparing their underlying topic name and partition numbers.
The sorting order described here allows us to track the TopicPartitionHistory
s in a fixed sliding window
naturally, with the oldest history item in the front and the latest history item at the back.
compareTo
in interface Comparable<TopicPartitionHistory>