public abstract class ResourceDistributionGoal extends ResourceDistributionAbstractGoal
Resource
distribution over brokers.ResourceDistributionAbstractGoal.ChangeType
fixOfflineReplicasOnly, initialResourceDistribution, moveImmigrantsOnly, requireLessLoad, requireMoreLoad, thresholds
balancingConstraint, finished, minMonitoredPartitionPercentage, numWindows, optimizationResultBuilder, proposalStatsBuilder
Constructor and Description |
---|
ResourceDistributionGoal() |
Modifier and Type | Method and Description |
---|---|
protected SortedSet<Broker> |
brokersToBalance(ClusterModel clusterModel)
Get brokers that the rebalance process will go over to apply balancing actions to replicas they contain.
|
protected void |
doRebalance(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
(1) REBALANCE BY LEADERSHIP MOVEMENT:
Perform leadership movement to ensure that the load on brokers for the outbound network and CPU load is under the
balance limit.
|
void |
finish()
Signal for finishing the process for rebalance or self-healing for this goal.
|
protected boolean |
isRebalanceByMovingLoadInCompleted(Broker broker) |
protected boolean |
isRebalanceByMovingLoadOutCompleted(Broker broker) |
ActionAcceptance |
replicaActionAcceptance(ReplicaBalancingAction action,
ClusterModel clusterModel)
Check whether given action is acceptable by this goal.
|
boolean |
replicaActionSelfSatisfied(ClusterModel clusterModel,
ReplicaBalancingAction action)
Check if requirements of this goal are not violated if this action is applied to the given cluster state,
false otherwise.
|
protected EntityFilter<Replica> |
replicaFilter()
Filter out replicas that are not relevant to the balancing algorithm of the goal.
|
protected abstract Resource |
resource() |
protected void |
updateGoalState(ClusterModel clusterModel,
Set<String> excludedTopics)
Update the current resource that is being balanced if there are still resources to be balanced, finish otherwise.
|
protected boolean |
validatePercentages()
Whether to verify the validity of the resource utilization percentages.
|
clusterModelCompletenessRequirements, clusterModelStatsComparator, initGoalState, isHardGoal, isLoadAboveBalanceLowerLimit, isLoadAboveBalanceLowerLimitAfterChange, isLoadUnderBalanceUpperLimit, isLoadUnderBalanceUpperLimitAfterChange, name, partitionActionAcceptance, partitionActionSelfSatisfied, performLeadershipMovement, performReplicaMovement, rebalanceForBroker, sortName
changeObservership, configure, maybeApplyBalancingAction, maybeApplyBalancingAction, maybeMoveReplicaBetweenDisks, optimize, proposalTrackingOptions, relocateReplica, selfSatisfied, shouldExclude, shouldExclude, shouldTryLeadershipMovement, toString, tryAcceptProposal, updateReplicationFactor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
actionAcceptance, canChangeReplicationFactor, optimize
protected abstract Resource resource()
resource
in class ResourceDistributionAbstractGoal
protected boolean validatePercentages()
ResourceDistributionAbstractGoal
validatePercentages
in class ResourceDistributionAbstractGoal
public ActionAcceptance replicaActionAcceptance(ReplicaBalancingAction action, ClusterModel clusterModel)
action
- Action to be checked for acceptance.clusterModel
- The state of the cluster.ActionAcceptance.ACCEPT
if the action is acceptable by this goal,
ActionAcceptance.REPLICA_REJECT
otherwise.protected SortedSet<Broker> brokersToBalance(ClusterModel clusterModel)
brokersToBalance
in class AbstractGoal
clusterModel
- The state of the cluster.public boolean replicaActionSelfSatisfied(ClusterModel clusterModel, ReplicaBalancingAction action)
clusterModel
- The state of the cluster.action
- Action containing information about potential modification to the given cluster model.protected void updateGoalState(ClusterModel clusterModel, Set<String> excludedTopics) throws OptimizationFailureException
updateGoalState
in class AbstractGoal
clusterModel
- The state of the cluster.excludedTopics
- The topics that should be excluded from the optimization action.OptimizationFailureException
public void finish()
Goal
finish
in interface Goal
finish
in class ResourceDistributionAbstractGoal
protected void doRebalance(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions)
(2) REBALANCE BY REPLICA MOVEMENT: Perform optimization via replica movement for the given resource (without breaking the balance for already balanced resources) to ensure rebalance: The load on brokers for the given resource is under the balance limit.
(3) REBALANCE BY REPLICA SWAP: Swap replicas to ensure balance without violating optimized goal requirements.
doRebalance
in class ResourceDistributionAbstractGoal
broker
- Broker to be balanced.clusterModel
- The state of the cluster.optimizedGoals
- Optimized goals.optimizationOptions
- Options to take into account during optimization -- e.g. excluded topics.protected EntityFilter<Replica> replicaFilter()
Note that this method modifies the provided set of replicas in place.
Goals may have a criteria upon which some broker replicas are not interesting for them
for the rebalance process. For example, the NetworkOutboundUsageDistributionGoal
can
filter out all follower replicas that do not have FFF load on them since it doesn't make sense
to move them.
The default implementation is to do nothing.
NoOpReplicaFilter
that does not filter out any replicasprotected boolean isRebalanceByMovingLoadOutCompleted(Broker broker)
isRebalanceByMovingLoadOutCompleted
in class ResourceDistributionAbstractGoal
protected boolean isRebalanceByMovingLoadInCompleted(Broker broker)
isRebalanceByMovingLoadInCompleted
in class ResourceDistributionAbstractGoal