public abstract class ResourceDistributionAbstractGoal extends AbstractGoal
Modifier and Type | Class and Description |
---|---|
protected static class |
ResourceDistributionAbstractGoal.ChangeType
Whether bring load in or bring load out.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
fixOfflineReplicasOnly |
protected Map<Integer,BrokerResourceStats> |
initialResourceDistribution |
protected boolean |
moveImmigrantsOnly |
protected boolean |
requireLessLoad |
protected boolean |
requireMoreLoad |
protected DistributionThresholdUtils.ResourcePercentageThresholds |
thresholds |
balancingConstraint, finished, minMonitoredPartitionPercentage, numWindows, optimizationResultBuilder, proposalStatsBuilder
Constructor and Description |
---|
ResourceDistributionAbstractGoal() |
Modifier and Type | Method and Description |
---|---|
ModelCompletenessRequirements |
clusterModelCompletenessRequirements()
Specify the load requirements for this goal.
|
ClusterModelStatsComparator |
clusterModelStatsComparator()
Get an instance of
ClusterModelStatsComparator for this goal. |
protected abstract void |
doRebalance(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
Performs the rebalance proposal generation.
|
void |
finish()
Signal for finishing the process for rebalance or self-healing for this goal.
|
protected void |
initGoalState(ClusterModel clusterModel,
OptimizationOptions optimizationOptions,
Optional<OptimizationMetrics> optimizationMetricsOpt)
Initialize the state of this goal.
|
boolean |
isHardGoal()
True if this is a hard goal, false otherwise.
|
protected boolean |
isLoadAboveBalanceLowerLimit(Broker broker)
Determine whether the resource utilization of the provided broker is above balance lower limit.
|
protected boolean |
isLoadAboveBalanceLowerLimitAfterChange(Load load,
Broker broker,
ResourceDistributionAbstractGoal.ChangeType changeType) |
protected boolean |
isLoadUnderBalanceUpperLimit(Broker broker)
Determine whether the resource utilization of the provided broker is under balance upper limit.
|
protected boolean |
isLoadUnderBalanceUpperLimitAfterChange(Load load,
Broker broker,
ResourceDistributionAbstractGoal.ChangeType changeType) |
protected abstract boolean |
isRebalanceByMovingLoadInCompleted(Broker broker) |
protected abstract boolean |
isRebalanceByMovingLoadOutCompleted(Broker broker) |
abstract String |
name()
Get the name of this goal.
|
ActionAcceptance |
partitionActionAcceptance(PartitionBalancingAction action,
ClusterModel clusterModel)
Checks if the action on the partition specified by the
PartitionBalancingAction
is acceptable. |
boolean |
partitionActionSelfSatisfied(ClusterModel clusterModel,
PartitionBalancingAction action)
Check if requirements of this goal are not violated if this partition action is applied
to the given cluster state, false otherwise.
|
protected void |
performLeadershipMovement(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions) |
protected void |
performReplicaMovement(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions) |
protected void |
rebalanceForBroker(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
Main entry point for proposing the movements to balance the given broker.
|
protected abstract Resource |
resource() |
protected String |
sortName() |
protected boolean |
validatePercentages()
Whether to verify the validity of the resource utilization percentages.
|
brokersToBalance, changeObservership, configure, maybeApplyBalancingAction, maybeApplyBalancingAction, maybeMoveReplicaBetweenDisks, optimize, proposalTrackingOptions, relocateReplica, selfSatisfied, shouldExclude, shouldExclude, shouldTryLeadershipMovement, toString, tryAcceptProposal, updateGoalState, updateReplicationFactor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
actionAcceptance, canChangeReplicationFactor, optimize
replicaActionAcceptance, replicaActionSelfSatisfied
protected boolean fixOfflineReplicasOnly
protected Map<Integer,BrokerResourceStats> initialResourceDistribution
protected DistributionThresholdUtils.ResourcePercentageThresholds thresholds
protected boolean requireLessLoad
protected boolean requireMoreLoad
protected boolean moveImmigrantsOnly
protected abstract Resource resource()
protected boolean validatePercentages()
public ActionAcceptance partitionActionAcceptance(PartitionBalancingAction action, ClusterModel clusterModel)
GoalBalancingActionAcceptance
PartitionBalancingAction
is acceptable.
For performance optimization purposes, it is recommended goals return the wider-level action acceptance first
(e.g ActionAcceptance.BROKER_REJECT
versus ActionAcceptance.REPLICA_REJECT
) as that helps
the proposal-generating logic short-circuit invalid proposal generations.action
- Action to be checked for acceptance.clusterModel
- State of the cluster before application of the action.public ClusterModelStatsComparator clusterModelStatsComparator()
Goal
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.public ModelCompletenessRequirements clusterModelCompletenessRequirements()
Goal
public abstract String name()
name
in interface Goal
name
in class AbstractGoal
public boolean isHardGoal()
Goal
public boolean partitionActionSelfSatisfied(ClusterModel clusterModel, PartitionBalancingAction action)
GoalBalancingActionAcceptance
clusterModel
- The state of the cluster.action
- Action containing information about potential modification to the given cluster model.public void finish()
Goal
protected void initGoalState(ClusterModel clusterModel, OptimizationOptions optimizationOptions, Optional<OptimizationMetrics> optimizationMetricsOpt) throws OptimizationFailureException
initGoalState
in class AbstractGoal
clusterModel
- The state of the cluster.optimizationOptions
- Options to take into account during optimization -- e.g. excluded topics.optimizationMetricsOpt
- An optional of OptimizationMetrics
used to capture various metrics throughout
this goal's optimization run.OptimizationFailureException
- when optimization encounters failureprotected void rebalanceForBroker(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions) throws OptimizationFailureException
doRebalance(Broker, ClusterModel, Set, OptimizationOptions)
method.rebalanceForBroker
in class AbstractGoal
broker
- Broker to be balancedclusterModel
- The state of the cluster.optimizedGoals
- Optimized goals.optimizationOptions
- Options to take into account during optimization -- e.g. excluded topics.OptimizationFailureException
- when optimization encounters failureprotected abstract void doRebalance(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions)
protected void performLeadershipMovement(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions)
protected void performReplicaMovement(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions)
protected abstract boolean isRebalanceByMovingLoadOutCompleted(Broker broker)
protected abstract boolean isRebalanceByMovingLoadInCompleted(Broker broker)
protected boolean isLoadAboveBalanceLowerLimit(Broker broker)
DistributionThresholdUtils.ResourcePercentageThresholds
.broker
- the broker to be testedprotected boolean isLoadUnderBalanceUpperLimit(Broker broker)
DistributionThresholdUtils.ResourcePercentageThresholds
.broker
- the broker to be testedprotected boolean isLoadAboveBalanceLowerLimitAfterChange(Load load, Broker broker, ResourceDistributionAbstractGoal.ChangeType changeType)
protected boolean isLoadUnderBalanceUpperLimitAfterChange(Load load, Broker broker, ResourceDistributionAbstractGoal.ChangeType changeType)
protected String sortName()