@InterfaceStability.Evolving public interface Goal extends CruiseControlConfigurable, GoalBalancingActionAcceptance
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 | Method and Description |
---|---|
default 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 ClusterModelStatsComparator |
clusterModelStatsComparator()
Get an instance of
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.
|
default GoalOptimizationResult |
optimize(ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
Optimize the given cluster model as needed for this goal.
|
GoalOptimizationResult |
optimize(ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions,
Optional<OptimizationMetrics> metricsOpt)
The method will be given a cluster model.
|
configure
partitionActionAcceptance, partitionActionSelfSatisfied, replicaActionAcceptance, replicaActionSelfSatisfied
default GoalOptimizationResult optimize(ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions) throws OptimizationFailureException
optimize(ClusterModel, Set, OptimizationOptions, Optional)
for more information.OptimizationFailureException
GoalOptimizationResult optimize(ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions, Optional<OptimizationMetrics> metricsOpt) throws OptimizationFailureException
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.metricsOpt
- An optional of a metrics object used to track various metrics related to this goal's optimization run.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 modeldefault ActionAcceptance actionAcceptance(BalancingAction action, ClusterModel clusterModel)
action
- Action to be checked for acceptance.clusterModel
- State of the cluster before application of the action.default ClusterModelStatsComparator clusterModelStatsComparator()
ClusterModelStatsComparator
for this goal.
The 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()