public abstract class ResourceDistributionGoal extends AbstractGoal
Resource
distribution over brokers.Modifier and Type | Class and Description |
---|---|
protected static class |
ResourceDistributionGoal.ChangeType
Whether bring load in or bring load out.
|
Goal.ClusterModelStatsComparator
balancingConstraint, finished, minMonitoredPartitionPercentage, numWindows, optimizationResultBuilder
Constructor and Description |
---|
ResourceDistributionGoal()
Constructor for Resource Distribution Goal.
|
Modifier and Type | Method and Description |
---|---|
ActionAcceptance |
actionAcceptance(BalancingAction action,
ClusterModel clusterModel)
Check whether given action is acceptable by this goal.
|
protected double |
balanceLowerThreshold() |
protected double |
balanceUpperThreshold() |
protected SortedSet<Broker> |
brokersToBalance(ClusterModel clusterModel)
Get brokers that the rebalance process will go over to apply balancing actions to replicas they contain.
|
ModelCompletenessRequirements |
clusterModelCompletenessRequirements()
Specify the load requirements for this goal.
|
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.
|
protected void |
initGoalState(ClusterModel clusterModel,
OptimizationOptions optimizationOptions)
(1) Initialize the current resource to be balanced or self healed.
|
boolean |
isHardGoal()
True if this is a hard goal, false otherwise.
|
abstract String |
name()
Get the name of this goal.
|
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 for the outbound network and CPU load is under the
balance limit.
|
protected abstract Resource |
resource() |
protected boolean |
selfSatisfied(ClusterModel clusterModel,
BalancingAction action)
Check if requirements of this goal are not violated if this action is applied to the given cluster state,
false otherwise.
|
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.
|
changeObservership, configure, maybeApplyBalancingAction, maybeMoveReplicaBetweenDisks, optimize, shouldExclude, toString, updateReplicationFactor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canChangeReplicationFactor
public ResourceDistributionGoal()
protected abstract Resource resource()
public ActionAcceptance actionAcceptance(BalancingAction 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 Goal.ClusterModelStatsComparator clusterModelStatsComparator()
Goal
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.public ModelCompletenessRequirements clusterModelCompletenessRequirements()
Goal
public abstract String name()
name
in interface Goal
name
in class AbstractGoal
public boolean isHardGoal()
Goal
protected SortedSet<Broker> brokersToBalance(ClusterModel clusterModel)
brokersToBalance
in class AbstractGoal
clusterModel
- The state of the cluster.protected boolean selfSatisfied(ClusterModel clusterModel, BalancingAction action)
selfSatisfied
in class AbstractGoal
clusterModel
- The state of the cluster.action
- Action containing information about potential modification to the given cluster model.protected void initGoalState(ClusterModel clusterModel, OptimizationOptions optimizationOptions)
initGoalState
in class AbstractGoal
clusterModel
- The state of the cluster.optimizationOptions
- Options to take into account during optimization.protected double balanceUpperThreshold()
protected double balanceLowerThreshold()
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)
(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.
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.