@InterfaceStability.Evolving public interface Goal extends CruiseControlConfigurable
See the Cruise Control configurations wiki for more details.
We have provided a helper AbstractGoal
class with some defined optimization steps to make the implementation
of the goals simpler.
Modifier and Type | Interface and Description |
---|---|
static interface |
Goal.ClusterModelStatsComparator
A comparator that compares two cluster model stats.
|
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.
|
default boolean |
canChangeReplicationFactor()
True if this goal can change replication factor of a topic
|
ModelCompletenessRequirements |
clusterModelCompletenessRequirements()
Specify the load requirements for this goal.
|
default Goal.ClusterModelStatsComparator |
clusterModelStatsComparator()
Get an instance of
Goal.ClusterModelStatsComparator for this goal. |
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.
|
configure
GoalOptimizationResult optimize(ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions) throws KafkaCruiseControlException
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
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.
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.OptimizationFailureException
- if the goal is a hard goal and it failed to optimize the given cluster modelKafkaCruiseControlException
ActionAcceptance actionAcceptance(BalancingAction action, ClusterModel clusterModel)
action
- Action to be checked for acceptance.clusterModel
- State of the cluster before application of the action.default Goal.ClusterModelStatsComparator clusterModelStatsComparator()
Goal.ClusterModelStatsComparator
for this goal.
The Goal.ClusterModelStatsComparator.compare(ClusterModelStats, ClusterModelStats)
method should give a
preference between two ClusterModelStats
.
Cruise Control will not reuse the returned instance.
The returned value must not be null.ModelCompletenessRequirements clusterModelCompletenessRequirements()
String name()
void finish()
boolean isHardGoal()
default boolean canChangeReplicationFactor()