public class ProposalGenerator extends Object implements GoalOptimizationHistoryListener<SuspendedTopicPartition>
Constructor and Description |
---|
ProposalGenerator(KafkaCruiseControlConfig config) |
Modifier and Type | Method and Description |
---|---|
OptimizerResult |
getProposals(ClusterModel clusterModel,
GoalsConfig goalsConfig,
boolean excludeRecentlyRemovedBrokers,
boolean isTriggeredByGoalViolation,
KafkaCruiseControlContext context) |
void |
onExpiredHistory(SuspendedTopicPartition expiredSuspension)
Called when history item is expired.
|
void |
onNewHistory(SuspendedTopicPartition newSuspension)
Called when new history item is recorded.
|
void |
onUpdatedEpoch(long newEpoch)
Update the history epoch of proposal generator and clear the suspended topic partitions with outdated epoch.
|
static Set<Integer> |
recentlyRemovedBrokers(KafkaCruiseControlContext context)
Get the set of broker IDs that have recently been removed from the cluster via a removeBrokers call.
|
public ProposalGenerator(KafkaCruiseControlConfig config)
public void onNewHistory(SuspendedTopicPartition newSuspension)
GoalOptimizationHistoryListener
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).
onNewHistory
in interface GoalOptimizationHistoryListener<SuspendedTopicPartition>
newSuspension
- new topic partition historypublic void onExpiredHistory(SuspendedTopicPartition expiredSuspension)
GoalOptimizationHistoryListener
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).
onExpiredHistory
in interface GoalOptimizationHistoryListener<SuspendedTopicPartition>
expiredSuspension
- expired topic partition historypublic void onUpdatedEpoch(long newEpoch)
onUpdatedEpoch
in interface GoalOptimizationHistoryListener<SuspendedTopicPartition>
newEpoch
- new epochfor the history cleaners
public static Set<Integer> recentlyRemovedBrokers(KafkaCruiseControlContext context)
public OptimizerResult getProposals(ClusterModel clusterModel, GoalsConfig goalsConfig, boolean excludeRecentlyRemovedBrokers, boolean isTriggeredByGoalViolation, KafkaCruiseControlContext context) throws KafkaCruiseControlException
KafkaCruiseControlException