public abstract class CapacityGoal extends AbstractGoal
balancingConstraint, finished, minMonitoredPartitionPercentage, numWindows, optimizationResultBuilder, proposalStatsBuilder
Constructor and Description |
---|
CapacityGoal()
Constructor for Capacity Goal.
|
Modifier and Type | Method and Description |
---|---|
protected SortedSet<Broker> |
brokersToBalance(ClusterModel clusterModel)
This is a hard goal; hence, the proposals are not limited to broken broker replicas in case of self-healing.
|
ModelCompletenessRequirements |
clusterModelCompletenessRequirements()
Specify the load requirements for this goal.
|
List<Broker> |
eligibleBrokersReplicaMove(ClusterModel clusterModel,
Resource resource)
Get a list of sorted (in ascending order by resource) eligible destination brokers having utilization
under: (given utilization threshold) * (broker and/or host capacity (see
Resource#isHostResource and Resource#isBrokerResource).
|
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)
Sanity checks: Existing total load on cluster is less than the limiting capacity
determined by the total capacity of alive cluster multiplied by the capacity threshold.
|
boolean |
isHardGoal()
True if this is a hard goal, false otherwise.
|
abstract String |
name()
Get the name of this goal.
|
ActionAcceptance |
partitionActionAcceptance(PartitionBalancingAction action,
ClusterModel clusterModel)
Check whether the given action is acceptable by this goal.
|
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 |
rebalanceForBroker(Broker broker,
ClusterModel clusterModel,
Set<Goal> optimizedGoals,
OptimizationOptions optimizationOptions)
(1) REBALANCE BY LEADERSHIP MOVEMENT:
Perform leadership movement to ensure that the load on brokers and/or hosts (see
Resource.isHostResource()
and Resource.isBrokerResource() ) for the outbound network load, produce-in load and CPU is under the capacity limit. |
ActionAcceptance |
replicaActionAcceptance(ReplicaBalancingAction action,
ClusterModel clusterModel)
Check whether the given action is acceptable by this goal.
|
boolean |
replicaActionSelfSatisfied(ClusterModel clusterModel,
ReplicaBalancingAction action)
This is a hard goal; hence, the proposals are not limited to broken broker replicas in case of self-healing.
|
protected abstract Resource |
resource() |
protected boolean |
shouldExcludeForReplicaMove(Replica replica)
Return a boolean indicating whether the replica should be excluded for a replica move (single-replica reassignment).
|
protected void |
updateGoalState(ClusterModel clusterModel,
Set<String> excludedTopics)
Update goal state.
|
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, clusterModelStatsComparator, optimize
public boolean isHardGoal()
Goal
protected abstract Resource resource()
public ActionAcceptance replicaActionAcceptance(ReplicaBalancingAction action, ClusterModel clusterModel)
DiskCapacityGoal.replicaActionAcceptance(ReplicaBalancingAction, ClusterModel)
and
NetworkInboundCapacityGoal.replicaActionAcceptance(ReplicaBalancingAction, ClusterModel)
).
(1) Check if leadership NW_OUT movement is acceptable: NW_OUT movement carries all of leader's NW_OUT load.
(2) Check if leadership CPU movement is acceptable: In reality, CPU movement carries only a fraction of
leader's CPU load.
To optimize CC performance, we avoid calculation of the expected leadership CPU utilization, and assume that
if (action.balancingAction() == ActionType.LEADERSHIP_MOVEMENT && resource() == Resource.CPU),
then the expected leadership CPU utilization would be the full CPU utilization of the leader.
(3) Check if leadership PRODUCE_IN movement is acceptable; Producers only produce to the leader replica.
## Replica Movement: impacts any resource. ## Replica Swap: impacts any resource.
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.public ActionAcceptance partitionActionAcceptance(PartitionBalancingAction 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.public ModelCompletenessRequirements clusterModelCompletenessRequirements()
Goal
public abstract String name()
name
in interface Goal
name
in class AbstractGoal
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.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.protected SortedSet<Broker> brokersToBalance(ClusterModel clusterModel)
brokersToBalance
in class AbstractGoal
clusterModel
- The state of the cluster.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.optimizationMetricsOpt
- An optional of an object to register metrics. Usually passed when evaluating self-healing.OptimizationFailureException
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
protected void rebalanceForBroker(Broker broker, ClusterModel clusterModel, Set<Goal> optimizedGoals, OptimizationOptions optimizationOptions) throws OptimizationFailureException
Resource.isHostResource()
and Resource.isBrokerResource()
) for the outbound network load, produce-in load and CPU is under the capacity limit.
(2) REBALANCE BY REPLICA MOVEMENT:
Perform optimization via replica movement for the given resource to ensure rebalance: The load on brokers and/or
hosts (see Resource.isHostResource()
and Resource.isBrokerResource()
) for the given resource is
under the capacity limit.
rebalanceForBroker
in class AbstractGoal
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.OptimizationFailureException
public List<Broker> eligibleBrokersReplicaMove(ClusterModel clusterModel, Resource resource)
clusterModel
- Current ClusterModel.resource
- Resource for which brokers will be sorted.protected boolean shouldExcludeForReplicaMove(Replica replica)