public class PreferredLeaderElectionGoal extends Object implements Goal
Goal.ClusterModelStatsComparator
Constructor and Description |
---|
PreferredLeaderElectionGoal() |
PreferredLeaderElectionGoal(boolean skipUrpDemotion,
boolean excludeFollowerDemotion,
org.apache.kafka.common.Cluster kafkaCluster) |
Modifier and Type | Method and Description |
---|---|
ActionAcceptance |
actionAcceptance(BalancingAction action,
ClusterModel clusterModel)
Check whether the given action is acceptable by this goal in the given state of the cluster.
|
ModelCompletenessRequirements |
clusterModelCompletenessRequirements()
Specify the load requirements for this goal.
|
void |
configure(Map<String,?> configs)
Configure this class with the given key-value pairs
|
void |
finish()
Signal for finishing the process for rebalance or self-healing for this goal.
|
boolean |
isHardGoal()
True if this is a hard goal, false otherwise.
|
String |
name()
Get the name of this goal.
|
GoalOptimizationResult |
optimize(ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
Optimize the given cluster model as needed for this goal.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canChangeReplicationFactor, clusterModelStatsComparator
public PreferredLeaderElectionGoal()
public PreferredLeaderElectionGoal(boolean skipUrpDemotion, boolean excludeFollowerDemotion, org.apache.kafka.common.Cluster kafkaCluster)
public GoalOptimizationResult optimize(ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions)
Goal
The method will be given a cluster model. The goal can try to optimize the cluster model by performing some admin operations (e.g. move replicas or leadership of partitions).
During the optimization, the implementation should make sure that all the previously optimized goals
are still satisfied after this method completes its execution. The implementation can use
Goal.actionAcceptance(BalancingAction, ClusterModel)
to check whether an admin operation
is allowed by a previously optimized goal.
The implementation of a soft goal should return a boolean indicating whether the goal has been met after the optimization or not.
The implementation of a hard goal should throw an OptimizationFailureException
when the goal
cannot be met. This will then fail the entire optimization attempt.
optimize
in interface Goal
clusterModel
- The cluster model reflecting the current state of the cluster. It is a result of the
optimization of the previously optimized goals.optimizedGoals
- Goals that have already been optimized. These goals cannot be violated.optimizationOptions
- Options to take into account during optimization -- e.g. excluded topics.GoalOptimizationResult
denoting whether the goal was met after the optimization and whether any replica movements were made.
Note that for hard goals, the implementation should just throw exceptions if the goal is not met.public ActionAcceptance actionAcceptance(BalancingAction action, ClusterModel clusterModel)
Goal
actionAcceptance
in interface Goal
action
- Action to be checked for acceptance.clusterModel
- State of the cluster before application of the action.public ModelCompletenessRequirements clusterModelCompletenessRequirements()
Goal
clusterModelCompletenessRequirements
in interface Goal
public String name()
Goal
public void finish()
Goal
public boolean isHardGoal()
Goal
isHardGoal
in interface Goal
public void configure(Map<String,?> configs)
CruiseControlConfigurable
configure
in interface CruiseControlConfigurable