Search in sources :

Example 16 with ProvisionRecommendation

use of com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation in project cruise-control by linkedin.

the class RackAwareGoal method ensureRackAware.

private void ensureRackAware(ClusterModel clusterModel, OptimizationOptions optimizationOptions) throws OptimizationFailureException {
    // Sanity check to confirm that the final distribution is rack aware.
    Set<String> excludedTopics = optimizationOptions.excludedTopics();
    for (Replica leader : clusterModel.leaderReplicas()) {
        if (excludedTopics.contains(leader.topicPartition().topic())) {
            continue;
        }
        Set<String> replicaBrokersRackIds = new HashSet<>();
        Set<Broker> followerBrokers = new HashSet<>(clusterModel.partition(leader.topicPartition()).followerBrokers());
        // Add rack Id of replicas.
        for (Broker followerBroker : followerBrokers) {
            String followerRackId = followerBroker.rack().id();
            replicaBrokersRackIds.add(followerRackId);
        }
        replicaBrokersRackIds.add(leader.broker().rack().id());
        if (replicaBrokersRackIds.size() != (followerBrokers.size() + 1)) {
            int missingRacks = (followerBrokers.size() + 1) - replicaBrokersRackIds.size();
            ProvisionRecommendation recommendation = new ProvisionRecommendation.Builder(ProvisionStatus.UNDER_PROVISIONED).numRacks(missingRacks).build();
            throw new OptimizationFailureException(String.format("[%s] Partition %s is not rack-aware. Leader (%s) and follower brokers (%s).", name(), leader.topicPartition(), leader.broker(), followerBrokers), recommendation);
        }
    }
}
Also used : ProvisionRecommendation(com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation) Broker(com.linkedin.kafka.cruisecontrol.model.Broker) OptimizationFailureException(com.linkedin.kafka.cruisecontrol.exception.OptimizationFailureException) Replica(com.linkedin.kafka.cruisecontrol.model.Replica) BalancingConstraint(com.linkedin.kafka.cruisecontrol.analyzer.BalancingConstraint) HashSet(java.util.HashSet)

Example 17 with ProvisionRecommendation

use of com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation in project cruise-control by linkedin.

the class CapacityGoal method postSanityCheck.

private void postSanityCheck(boolean utilizationOverLimit, Broker broker, double brokerCapacityLimit, double hostCapacityLimit) throws OptimizationFailureException {
    // 1. Capacity violation check -- note that this check also ensures that no replica resides on dead brokers.
    if (utilizationOverLimit) {
        Resource currentResource = resource();
        ProvisionRecommendation recommendation = new ProvisionRecommendation.Builder(ProvisionStatus.UNDER_PROVISIONED).numBrokers(1).resource(currentResource).build();
        if (!currentResource.isHostResource()) {
            // Utilization is above the capacity limit after all replicas in the given source broker were checked.
            throw new OptimizationFailureException(String.format("[%s] Utilization (%.2f) of broker %d violated capacity limit (%.2f) for resource %s.", name(), broker.load().expectedUtilizationFor(currentResource), broker.id(), brokerCapacityLimit, currentResource), recommendation);
        } else {
            throw new OptimizationFailureException(String.format("[%s] Utilization (%.2f) of host %s violated capacity limit (%.2f) for resource %s.", name(), broker.host().load().expectedUtilizationFor(currentResource), broker.host().name(), hostCapacityLimit, currentResource), recommendation);
        }
    }
    // 2. Ensure that no offline replicas remain in the broker.
    if (!broker.currentOfflineReplicas().isEmpty()) {
        ProvisionRecommendation recommendation = new ProvisionRecommendation.Builder(ProvisionStatus.UNDER_PROVISIONED).numBrokers(1).resource(resource()).build();
        throw new OptimizationFailureException(String.format("[%s] Cannot remove offline replicas from broker %d.", name(), broker.id()), recommendation);
    }
}
Also used : ProvisionRecommendation(com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation) OptimizationFailureException(com.linkedin.kafka.cruisecontrol.exception.OptimizationFailureException) Resource(com.linkedin.kafka.cruisecontrol.common.Resource)

Example 18 with ProvisionRecommendation

use of com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation in project cruise-control by linkedin.

the class GoalUtils method ensureNoOfflineReplicas.

/**
 * Checks the replicas that are supposed to be moved away from the dead brokers or broken disks have been moved.
 * If there are still replicas on the dead brokers or broken disks, throws an exception.
 * @param clusterModel the cluster model to check.
 * @param goalName Goal name for which the sanity check is executed.
 * @throws OptimizationFailureException when there are still replicas on the dead brokers or on broken disks.
 */
public static void ensureNoOfflineReplicas(ClusterModel clusterModel, String goalName) throws OptimizationFailureException {
    // Sanity check: No self-healing eligible replica should remain at a decommissioned broker or on broken disk.
    for (Replica replica : clusterModel.selfHealingEligibleReplicas()) {
        if (replica.isCurrentOffline()) {
            ProvisionRecommendation recommendation = new ProvisionRecommendation.Builder(ProvisionStatus.UNDER_PROVISIONED).numBrokers(1).build();
            Broker broker = replica.broker();
            throw new OptimizationFailureException(String.format("[%s] Cannot remove %s from %s broker %d (has %d replicas).", goalName, replica, broker.state(), broker.id(), broker.replicas().size()), recommendation);
        }
    }
}
Also used : ProvisionRecommendation(com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation) Broker(com.linkedin.kafka.cruisecontrol.model.Broker) OptimizationFailureException(com.linkedin.kafka.cruisecontrol.exception.OptimizationFailureException) Replica(com.linkedin.kafka.cruisecontrol.model.Replica)

Example 19 with ProvisionRecommendation

use of com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation in project cruise-control by linkedin.

the class IntraBrokerDiskCapacityGoal method updateGoalState.

/**
 * Update goal state.
 * Sanity check: After completion of balancing the resource, confirm that the utilization is under the capacity and finish.
 *
 * @param clusterModel The state of the cluster.
 * @param optimizationOptions Options to take into account during optimization.
 */
@Override
protected void updateGoalState(ClusterModel clusterModel, OptimizationOptions optimizationOptions) throws OptimizationFailureException {
    for (Broker broker : brokersToBalance(clusterModel)) {
        for (Disk disk : broker.disks()) {
            if (disk.isAlive() && isUtilizationOverLimit(disk)) {
                // The utilization of the host for the resource is over the capacity limit.
                double requiredCapacity = disk.utilization() / _balancingConstraint.capacityThreshold(RESOURCE);
                ProvisionRecommendation recommendation = new ProvisionRecommendation.Builder(ProvisionStatus.UNDER_PROVISIONED).numDisks(1).totalCapacity(requiredCapacity).build();
                throw new OptimizationFailureException(String.format("[%s] Utilization (%.2f) for disk %s on broker %d is above capacity limit.", name(), disk.utilization(), disk, broker.id()), recommendation);
            }
        }
    }
    finish();
}
Also used : ProvisionRecommendation(com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation) Broker(com.linkedin.kafka.cruisecontrol.model.Broker) OptimizationFailureException(com.linkedin.kafka.cruisecontrol.exception.OptimizationFailureException) Disk(com.linkedin.kafka.cruisecontrol.model.Disk)

Example 20 with ProvisionRecommendation

use of com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation in project cruise-control by linkedin.

the class RightsizeRequest method handle.

@Override
protected RightsizeResult handle() {
    KafkaCruiseControlConfig config = _kafkaCruiseControl.config();
    ProvisionRecommendation recommendation = createProvisionRecommendation();
    Map<String, ProvisionRecommendation> provisionRecommendation;
    provisionRecommendation = Collections.singletonMap(RECOMMENDER_UP, recommendation);
    ProvisionerState provisionerState = _kafkaCruiseControl.provisioner().rightsize(provisionRecommendation, new RightsizeOptions());
    return new RightsizeResult(recommendation, provisionerState, config);
}
Also used : RightsizeResult(com.linkedin.kafka.cruisecontrol.servlet.response.RightsizeResult) ProvisionRecommendation(com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation) KafkaCruiseControlConfig(com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig) ProvisionerState(com.linkedin.kafka.cruisecontrol.detector.ProvisionerState) RightsizeOptions(com.linkedin.kafka.cruisecontrol.detector.RightsizeOptions)

Aggregations

ProvisionRecommendation (com.linkedin.kafka.cruisecontrol.analyzer.ProvisionRecommendation)22 OptimizationFailureException (com.linkedin.kafka.cruisecontrol.exception.OptimizationFailureException)18 Broker (com.linkedin.kafka.cruisecontrol.model.Broker)11 BalancingConstraint (com.linkedin.kafka.cruisecontrol.analyzer.BalancingConstraint)8 Replica (com.linkedin.kafka.cruisecontrol.model.Replica)7 SortedReplicasHelper (com.linkedin.kafka.cruisecontrol.model.SortedReplicasHelper)7 HashSet (java.util.HashSet)4 ProvisionResponse (com.linkedin.kafka.cruisecontrol.analyzer.ProvisionResponse)3 Map (java.util.Map)3 Resource (com.linkedin.kafka.cruisecontrol.common.Resource)2 ActionAcceptance (com.linkedin.kafka.cruisecontrol.analyzer.ActionAcceptance)1 ACCEPT (com.linkedin.kafka.cruisecontrol.analyzer.ActionAcceptance.ACCEPT)1 BROKER_REJECT (com.linkedin.kafka.cruisecontrol.analyzer.ActionAcceptance.BROKER_REJECT)1 REPLICA_REJECT (com.linkedin.kafka.cruisecontrol.analyzer.ActionAcceptance.REPLICA_REJECT)1 ActionType (com.linkedin.kafka.cruisecontrol.analyzer.ActionType)1 BalancingAction (com.linkedin.kafka.cruisecontrol.analyzer.BalancingAction)1 OptimizationOptions (com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions)1 ProvisionStatus (com.linkedin.kafka.cruisecontrol.analyzer.ProvisionStatus)1 MIN_NUM_VALID_WINDOWS_FOR_SELF_HEALING (com.linkedin.kafka.cruisecontrol.analyzer.goals.GoalUtils.MIN_NUM_VALID_WINDOWS_FOR_SELF_HEALING)1 GoalUtils.replicaSortName (com.linkedin.kafka.cruisecontrol.analyzer.goals.GoalUtils.replicaSortName)1