H
- type of TopicPartitionHistory
public interface GoalOptimizationHistoryListener<H extends TopicPartitionHistory>
GoalOptimizationHistory
.
Important: All implementation should be non-blocking.Modifier and Type | Method and Description |
---|---|
void |
onExpiredHistory(H topicPartitionHistory)
Called when history item is expired.
|
void |
onNewHistory(H topicPartitionHistory)
Called when new history item is recorded.
|
void |
onUpdatedEpoch(long newEpoch)
Called when epoch is bumped.
|
void onNewHistory(H topicPartitionHistory)
1. non-blocking so that notifications can be delivered efficiently.
2. apply updates to listener's local state following TopicPartitionHistory
's chronological order. Due to
the concurrency nature of the notification mechanisms, it is possible for GoalOptimizationHistory
to send
out notifications of old topic partition history items later than new topic partition history items. It is the
listeners' responsibility to ensure that states from new history items are not overwritten by older history items.
An easy way to achieve this is to compare the locally stored topic partition history with the new one using the
TopicPartitionHistory.compareTo(TopicPartitionHistory)
method, and only apply the change if the received
topic partition history is larger (i.e. later in the time).
topicPartitionHistory
- new topic partition historyvoid onExpiredHistory(H topicPartitionHistory)
1. non-blocking so that notifications can be delivered efficiently.
2. apply updates to listener's local state following TopicPartitionHistory
's chronological order. Due to
the concurrency nature of the notification mechanisms, it is possible for GoalOptimizationHistory
to send
out notifications of old topic partition history items later than new topic partition history items. It is the
listeners' responsibility to ensure that states from new history items are not overwritten by older history items.
An easy way to achieve this is to compare the locally stored topic partition history with the new one using the
TopicPartitionHistory.compareTo(TopicPartitionHistory)
method, and only apply the change if the received
topic partition history is larger (i.e. later in the time).
topicPartitionHistory
- expired topic partition historyvoid onUpdatedEpoch(long newEpoch)
1. non-blocking so that notifications can be delivered efficiently.
2. apply updates to listener's local epoch in monotonic order. Due to the concurrency nature of the notification
mechanisms, it is possible for GoalOptimizationHistory
to send out notifications of old epoch later than
new epoch. It is the listeners' responsibility to ensure that the epoch is always updated monotonically in
ascending order. An easy way to achieve this is to compare the listener's local epoch with the epoch in the
notification and take the bigger one as the new epoch.
newEpoch
- new epochTopicPartitionHistory.epoch()