Search in sources :

Example 1 with OptimizerResult

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

the class DemoteBrokerRunnable method workWithClusterModel.

@Override
protected OptimizerResult workWithClusterModel() throws KafkaCruiseControlException, TimeoutException, NotEnoughValidWindowsException {
    ensureDisjoint(_brokerIds, _brokerIdAndLogdirs.keySet(), "Attempt to demote the broker and its disk in the same request is not allowed.");
    Set<Integer> brokersToCheckPresence = new HashSet<>(_brokerIds);
    brokersToCheckPresence.addAll(_brokerIdAndLogdirs.keySet());
    _kafkaCruiseControl.sanityCheckBrokerPresence(brokersToCheckPresence);
    ClusterModel clusterModel = _brokerIdAndLogdirs.isEmpty() ? _kafkaCruiseControl.clusterModel(_combinedCompletenessRequirements, _allowCapacityEstimation, _operationProgress) : _kafkaCruiseControl.clusterModel(DEFAULT_START_TIME_FOR_CLUSTER_MODEL, _kafkaCruiseControl.timeMs(), _combinedCompletenessRequirements, true, _allowCapacityEstimation, _operationProgress);
    setDemoteState(clusterModel);
    OptimizationOptions optimizationOptions = computeOptimizationOptions(clusterModel, false, _kafkaCruiseControl, Collections.emptySet(), _dryRun, _excludeRecentlyDemotedBrokers, _excludeRecentlyRemovedBrokers, _excludedTopics, Collections.emptySet(), false, _fastMode);
    OptimizerResult result = _kafkaCruiseControl.optimizations(clusterModel, _goalsByPriority, _operationProgress, null, optimizationOptions);
    if (!_dryRun) {
        _kafkaCruiseControl.executeDemotion(result.goalProposals(), _brokerIds, _concurrentLeaderMovements, clusterModel.brokers().size(), _executionProgressCheckIntervalMs, _replicaMovementStrategy, _replicationThrottle, _isTriggeredByUserRequest, _uuid);
    }
    return result;
}
Also used : ClusterModel(com.linkedin.kafka.cruisecontrol.model.ClusterModel) OptimizationOptions(com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions) RunnableUtils.computeOptimizationOptions(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RunnableUtils.computeOptimizationOptions) OptimizerResult(com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult) HashSet(java.util.HashSet)

Example 2 with OptimizerResult

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

the class UpdateTopicConfigurationRunnable method workWithClusterModel.

@Override
protected OptimizerResult workWithClusterModel() throws KafkaCruiseControlException, TimeoutException, NotEnoughValidWindowsException {
    Map<String, List<Integer>> brokersByRack = new HashMap<>();
    Map<Integer, String> rackByBroker = new HashMap<>();
    ClusterModel clusterModel = _kafkaCruiseControl.clusterModel(_combinedCompletenessRequirements, _allowCapacityEstimation, _operationProgress);
    if (!clusterModel.isClusterAlive()) {
        throw new IllegalArgumentException("All brokers are dead in the cluster.");
    }
    OptimizationOptions optimizationOptions = computeOptimizationOptions(clusterModel, false, _kafkaCruiseControl, Collections.emptySet(), _dryRun, _excludeRecentlyDemotedBrokers, _excludeRecentlyRemovedBrokers, _excludedTopics, Collections.emptySet(), true, _fastMode);
    populateRackInfoForReplicationFactorChange(_topicsToChangeByReplicationFactor, _cluster, _skipRackAwarenessCheck, brokersByRack, rackByBroker);
    Map<TopicPartition, List<ReplicaPlacementInfo>> initReplicaDistribution = clusterModel.getReplicaDistribution();
    // First try to add and remove replicas to achieve the replication factor for topics of interest.
    clusterModel.createOrDeleteReplicas(_topicsToChangeByReplicationFactor, brokersByRack, rackByBroker, _cluster);
    // Then further optimize the location of newly added replicas based on goals. Here we restrict the replica movement to
    // only considering newly added replicas, in order to minimize the total bytes to move.
    OptimizerResult result = _kafkaCruiseControl.optimizations(clusterModel, _goalsByPriority, _operationProgress, initReplicaDistribution, optimizationOptions);
    if (!_dryRun) {
        _kafkaCruiseControl.executeProposals(result.goalProposals(), Collections.emptySet(), false, _concurrentInterBrokerPartitionMovements, _maxInterBrokerPartitionMovements, 0, _concurrentLeaderMovements, _executionProgressCheckIntervalMs, _replicaMovementStrategy, _replicationThrottle, _isTriggeredByUserRequest, _uuid, SKIP_AUTO_REFRESHING_CONCURRENCY);
    }
    return result;
}
Also used : ClusterModel(com.linkedin.kafka.cruisecontrol.model.ClusterModel) OptimizationOptions(com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions) RunnableUtils.computeOptimizationOptions(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RunnableUtils.computeOptimizationOptions) HashMap(java.util.HashMap) TopicPartition(org.apache.kafka.common.TopicPartition) OptimizerResult(com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult) List(java.util.List)

Example 3 with OptimizerResult

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

the class AddBrokersRunnable method workWithClusterModel.

@Override
protected OptimizerResult workWithClusterModel() throws KafkaCruiseControlException, TimeoutException, NotEnoughValidWindowsException {
    _kafkaCruiseControl.sanityCheckBrokerPresence(_brokerIds);
    ClusterModel clusterModel = _kafkaCruiseControl.clusterModel(_combinedCompletenessRequirements, _allowCapacityEstimation, _operationProgress);
    sanityCheckBrokersHavingOfflineReplicasOnBadDisks(_goals, clusterModel);
    _brokerIds.forEach(id -> clusterModel.setBrokerState(id, Broker.State.NEW));
    if (!clusterModel.isClusterAlive()) {
        throw new IllegalArgumentException("All brokers are dead in the cluster.");
    }
    OptimizationOptions optimizationOptions = computeOptimizationOptions(clusterModel, false, _kafkaCruiseControl, _brokerIds, _dryRun, _excludeRecentlyDemotedBrokers, _excludeRecentlyRemovedBrokers, _excludedTopics, Collections.emptySet(), false, _fastMode);
    OptimizerResult result = _kafkaCruiseControl.optimizations(clusterModel, _goalsByPriority, _operationProgress, null, optimizationOptions);
    if (!_dryRun) {
        _kafkaCruiseControl.executeProposals(result.goalProposals(), _throttleAddedBrokers ? Collections.emptySet() : _brokerIds, isKafkaAssignerMode(_goals), _concurrentInterBrokerPartitionMovements, _maxInterBrokerPartitionMovements, null, _concurrentLeaderMovements, _executionProgressCheckIntervalMs, _replicaMovementStrategy, _replicationThrottle, _isTriggeredByUserRequest, _uuid, SKIP_AUTO_REFRESHING_CONCURRENCY);
    }
    return result;
}
Also used : ClusterModel(com.linkedin.kafka.cruisecontrol.model.ClusterModel) OptimizationOptions(com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions) RunnableUtils.computeOptimizationOptions(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RunnableUtils.computeOptimizationOptions) OptimizerResult(com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult)

Example 4 with OptimizerResult

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

the class FixOfflineReplicasRunnable method workWithClusterModel.

@Override
protected OptimizerResult workWithClusterModel() throws KafkaCruiseControlException, TimeoutException, NotEnoughValidWindowsException {
    ClusterModel clusterModel = _kafkaCruiseControl.clusterModel(_combinedCompletenessRequirements, _allowCapacityEstimation, _operationProgress);
    // Ensure that the generated cluster model contains offline replicas.
    sanityCheckOfflineReplicaPresence(clusterModel);
    if (!clusterModel.isClusterAlive()) {
        throw new IllegalArgumentException("All brokers are dead in the cluster.");
    }
    OptimizationOptions optimizationOptions = computeOptimizationOptions(clusterModel, false, _kafkaCruiseControl, Collections.emptySet(), _dryRun, _excludeRecentlyDemotedBrokers, _excludeRecentlyRemovedBrokers, _excludedTopics, Collections.emptySet(), false, _fastMode);
    OptimizerResult result = _kafkaCruiseControl.optimizations(clusterModel, _goalsByPriority, _operationProgress, null, optimizationOptions);
    if (!_dryRun) {
        _kafkaCruiseControl.executeProposals(result.goalProposals(), Collections.emptySet(), false, _concurrentInterBrokerPartitionMovements, _maxInterBrokerPartitionMovements, null, _concurrentLeaderMovements, _executionProgressCheckIntervalMs, _replicaMovementStrategy, _replicationThrottle, _isTriggeredByUserRequest, _uuid, SKIP_AUTO_REFRESHING_CONCURRENCY);
    }
    return result;
}
Also used : ClusterModel(com.linkedin.kafka.cruisecontrol.model.ClusterModel) OptimizationOptions(com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions) OptimizerResult(com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult)

Example 5 with OptimizerResult

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

the class RebalanceRunnable method workWithoutClusterModel.

@Override
protected OptimizerResult workWithoutClusterModel() throws KafkaCruiseControlException {
    ProposalsRunnable proposalsRunnable = new ProposalsRunnable(_kafkaCruiseControl, _future, _goals, _modelCompletenessRequirements, _allowCapacityEstimation, _excludedTopics, _excludeRecentlyDemotedBrokers, _excludeRecentlyRemovedBrokers, _ignoreProposalCache, _destinationBrokerIds, _isRebalanceDiskMode, _skipHardGoalCheck, !_isTriggeredByUserRequest, _fastMode);
    OptimizerResult result = proposalsRunnable.computeResult();
    if (!_dryRun) {
        _kafkaCruiseControl.executeProposals(result.goalProposals(), Collections.emptySet(), isKafkaAssignerMode(_goals), _concurrentInterBrokerPartitionMovements, _maxInterBrokerPartitionMovements, _concurrentIntraBrokerPartitionMovements, _concurrentLeaderMovements, _executionProgressCheckIntervalMs, _replicaMovementStrategy, _replicationThrottle, _isTriggeredByUserRequest, _uuid, SKIP_AUTO_REFRESHING_CONCURRENCY);
    }
    return result;
}
Also used : OptimizerResult(com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult)

Aggregations

OptimizerResult (com.linkedin.kafka.cruisecontrol.analyzer.OptimizerResult)8 ClusterModel (com.linkedin.kafka.cruisecontrol.model.ClusterModel)6 OptimizationOptions (com.linkedin.kafka.cruisecontrol.analyzer.OptimizationOptions)5 RunnableUtils.computeOptimizationOptions (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RunnableUtils.computeOptimizationOptions)4 HashMap (java.util.HashMap)2 Anomaly (com.linkedin.cruisecontrol.detector.Anomaly)1 NotEnoughValidWindowsException (com.linkedin.cruisecontrol.exception.NotEnoughValidWindowsException)1 KafkaCruiseControl (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)1 DeterministicCluster.generateClusterFromClusterModel (com.linkedin.kafka.cruisecontrol.common.DeterministicCluster.generateClusterFromClusterModel)1 DeterministicCluster.smallClusterModel (com.linkedin.kafka.cruisecontrol.common.DeterministicCluster.smallClusterModel)1 KafkaCruiseControlConfig (com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig)1 AnomalyNotifier (com.linkedin.kafka.cruisecontrol.detector.notifier.AnomalyNotifier)1 KafkaCruiseControlException (com.linkedin.kafka.cruisecontrol.exception.KafkaCruiseControlException)1 ExecutorState (com.linkedin.kafka.cruisecontrol.executor.ExecutorState)1 ModelCompletenessRequirements (com.linkedin.kafka.cruisecontrol.monitor.ModelCompletenessRequirements)1 BrokerEntity (com.linkedin.kafka.cruisecontrol.monitor.sampling.holder.BrokerEntity)1 BrokerStats (com.linkedin.kafka.cruisecontrol.servlet.response.stats.BrokerStats)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1