Search in sources :

Example 1 with RemoveBrokersRunnable

use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable in project cruise-control by linkedin.

the class SlowBrokers method configure.

@Override
public void configure(Map<String, ?> configs) {
    super.configure(configs);
    KafkaCruiseControl kafkaCruiseControl = extractKafkaCruiseControlObjectFromConfig(configs, KafkaAnomalyType.METRIC_ANOMALY);
    if (_fixable) {
        Boolean removeSlowBroker = (Boolean) configs.get(SlowBrokerFinder.REMOVE_SLOW_BROKER_CONFIG);
        if (removeSlowBroker == null) {
            throw new IllegalArgumentException(String.format("Missing %s for slow broker anomaly.", SlowBrokerFinder.REMOVE_SLOW_BROKER_CONFIG));
        }
        KafkaCruiseControlConfig config = kafkaCruiseControl.config();
        boolean allowCapacityEstimation = config.getBoolean(ANOMALY_DETECTION_ALLOW_CAPACITY_ESTIMATION_CONFIG);
        boolean excludeRecentlyDemotedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_DEMOTED_BROKERS_CONFIG);
        boolean excludeRecentlyRemovedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_REMOVED_BROKERS_CONFIG);
        if (removeSlowBroker) {
            _removeBrokersRunnable = new RemoveBrokersRunnable(kafkaCruiseControl, _brokerEntitiesWithDetectionTimeMs.keySet().stream().mapToInt(BrokerEntity::brokerId).boxed().collect(Collectors.toSet()), getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
        } else {
            _demoteBrokerRunnable = new DemoteBrokerRunnable(kafkaCruiseControl, _brokerEntitiesWithDetectionTimeMs.keySet().stream().mapToInt(BrokerEntity::brokerId).boxed().collect(Collectors.toSet()), allowCapacityEstimation, excludeRecentlyDemotedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
        }
    }
}
Also used : KafkaCruiseControl(com.linkedin.kafka.cruisecontrol.KafkaCruiseControl) KafkaCruiseControlConfig(com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig) RemoveBrokersRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable) BrokerEntity(com.linkedin.kafka.cruisecontrol.monitor.sampling.holder.BrokerEntity) DemoteBrokerRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.DemoteBrokerRunnable)

Example 2 with RemoveBrokersRunnable

use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable in project cruise-control by linkedin.

the class RemoveBrokerRequest method handle.

@Override
protected OperationFuture handle(String uuid) {
    OperationFuture future = new OperationFuture("Remove brokers");
    pending(future.operationProgress());
    _asyncKafkaCruiseControl.sessionExecutor().submit(new RemoveBrokersRunnable(_asyncKafkaCruiseControl, future, _parameters, uuid));
    return future;
}
Also used : RemoveBrokersRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable) OperationFuture(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture)

Example 3 with RemoveBrokersRunnable

use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable in project cruise-control by linkedin.

the class BrokerFailures method configure.

@SuppressWarnings("unchecked")
@Override
public void configure(Map<String, ?> configs) {
    super.configure(configs);
    KafkaCruiseControl kafkaCruiseControl = extractKafkaCruiseControlObjectFromConfig(configs, BROKER_FAILURE);
    _failedBrokers = (Map<Integer, Long>) configs.get(BrokerFailureDetector.FAILED_BROKERS_OBJECT_CONFIG);
    if (_failedBrokers != null && _failedBrokers.isEmpty()) {
        throw new IllegalArgumentException("Missing broker ids for failed brokers anomaly.");
    }
    _fixable = (Boolean) configs.get(BrokerFailureDetector.BROKER_FAILURES_FIXABLE_CONFIG);
    _optimizationResult = null;
    KafkaCruiseControlConfig config = kafkaCruiseControl.config();
    boolean allowCapacityEstimation = config.getBoolean(ANOMALY_DETECTION_ALLOW_CAPACITY_ESTIMATION_CONFIG);
    boolean excludeRecentlyDemotedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_DEMOTED_BROKERS_CONFIG);
    boolean excludeRecentlyRemovedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_REMOVED_BROKERS_CONFIG);
    _removeBrokersRunnable = _failedBrokers != null ? new RemoveBrokersRunnable(kafkaCruiseControl, _failedBrokers.keySet(), getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution()) : null;
}
Also used : KafkaCruiseControl(com.linkedin.kafka.cruisecontrol.KafkaCruiseControl) KafkaCruiseControlConfig(com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig) RemoveBrokersRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable)

Example 4 with RemoveBrokersRunnable

use of com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable in project cruise-control by linkedin.

the class MaintenanceEvent method configure.

@Override
public void configure(Map<String, ?> configs) {
    super.configure(configs);
    KafkaCruiseControl kafkaCruiseControl = extractKafkaCruiseControlObjectFromConfig(configs, MAINTENANCE_EVENT);
    KafkaCruiseControlConfig config = kafkaCruiseControl.config();
    boolean allowCapacityEstimation = config.getBoolean(ANOMALY_DETECTION_ALLOW_CAPACITY_ESTIMATION_CONFIG);
    boolean excludeRecentlyDemotedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_DEMOTED_BROKERS_CONFIG);
    boolean excludeRecentlyRemovedBrokers = config.getBoolean(SELF_HEALING_EXCLUDE_RECENTLY_REMOVED_BROKERS_CONFIG);
    boolean skipRackAwarenessCheck = config.getBoolean(RF_SELF_HEALING_SKIP_RACK_AWARENESS_CHECK_CONFIG);
    _optimizationResult = null;
    _maintenanceEventType = (MaintenanceEventType) configs.get(MAINTENANCE_EVENT_TYPE_CONFIG);
    _stopOngoingExecution = (Boolean) configs.get(MAINTENANCE_EVENT_STOP_ONGOING_EXECUTION_CONFIG);
    switch(_maintenanceEventType) {
        case ADD_BROKER:
            initBrokers(configs);
            _goalBasedOperationRunnable = new AddBrokersRunnable(kafkaCruiseControl, _brokers, getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
            break;
        case REMOVE_BROKER:
            initBrokers(configs);
            _goalBasedOperationRunnable = new RemoveBrokersRunnable(kafkaCruiseControl, _brokers, getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
            break;
        case FIX_OFFLINE_REPLICAS:
            _goalBasedOperationRunnable = new FixOfflineReplicasRunnable(kafkaCruiseControl, getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
            break;
        case REBALANCE:
            _goalBasedOperationRunnable = new RebalanceRunnable(kafkaCruiseControl, getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
            break;
        case DEMOTE_BROKER:
            initBrokers(configs);
            _goalBasedOperationRunnable = new DemoteBrokerRunnable(kafkaCruiseControl, _brokers, allowCapacityEstimation, excludeRecentlyDemotedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution());
            break;
        case TOPIC_REPLICATION_FACTOR:
            Map<Short, Pattern> topicPatternByReplicationFactor = topicPatternByReplicationFactor(configs);
            _goalBasedOperationRunnable = new UpdateTopicConfigurationRunnable(kafkaCruiseControl, topicPatternByReplicationFactor, getSelfHealingGoalNames(config), allowCapacityEstimation, excludeRecentlyDemotedBrokers, excludeRecentlyRemovedBrokers, _anomalyId.toString(), reasonSupplier(), stopOngoingExecution(), skipRackAwarenessCheck);
            break;
        default:
            throw new IllegalStateException(String.format("Unsupported maintenance event type %s.", _maintenanceEventType));
    }
}
Also used : Pattern(java.util.regex.Pattern) KafkaCruiseControl(com.linkedin.kafka.cruisecontrol.KafkaCruiseControl) RemoveBrokersRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable) AddBrokersRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.AddBrokersRunnable) RebalanceRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RebalanceRunnable) DemoteBrokerRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.DemoteBrokerRunnable) FixOfflineReplicasRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.FixOfflineReplicasRunnable) KafkaCruiseControlConfig(com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig) UpdateTopicConfigurationRunnable(com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.UpdateTopicConfigurationRunnable)

Aggregations

RemoveBrokersRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RemoveBrokersRunnable)4 KafkaCruiseControl (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)3 KafkaCruiseControlConfig (com.linkedin.kafka.cruisecontrol.config.KafkaCruiseControlConfig)3 DemoteBrokerRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.DemoteBrokerRunnable)2 BrokerEntity (com.linkedin.kafka.cruisecontrol.monitor.sampling.holder.BrokerEntity)1 AddBrokersRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.AddBrokersRunnable)1 FixOfflineReplicasRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.FixOfflineReplicasRunnable)1 OperationFuture (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.OperationFuture)1 RebalanceRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.RebalanceRunnable)1 UpdateTopicConfigurationRunnable (com.linkedin.kafka.cruisecontrol.servlet.handler.async.runnable.UpdateTopicConfigurationRunnable)1 Pattern (java.util.regex.Pattern)1