use of io.strimzi.operator.cluster.operator.resource.cruisecontrol.CruiseControlRebalanceResponse in project strimzi by strimzi.
the class KafkaRebalanceAssemblyOperator method requestRebalance.
private Future<MapAndStatus<ConfigMap, KafkaRebalanceStatus>> requestRebalance(Reconciliation reconciliation, String host, CruiseControlApi apiClient, KafkaRebalance kafkaRebalance, boolean dryrun, AbstractRebalanceOptions.AbstractRebalanceOptionsBuilder<?, ?> rebalanceOptionsBuilder, String userTaskID) {
LOGGER.infoCr(reconciliation, "Requesting Cruise Control rebalance [dryrun={}]", dryrun);
rebalanceOptionsBuilder.withVerboseResponse();
if (!dryrun) {
rebalanceOptionsBuilder.withFullRun();
}
// backward compatibility, no mode specified means "full"
KafkaRebalanceMode mode = Optional.ofNullable(kafkaRebalance.getSpec()).map(spec -> spec.getMode()).orElse(KafkaRebalanceMode.FULL);
Future<CruiseControlRebalanceResponse> future;
switch(mode) {
case ADD_BROKERS:
future = apiClient.addBroker(host, CruiseControl.REST_API_PORT, ((AddBrokerOptions.AddBrokerOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
case REMOVE_BROKERS:
future = apiClient.removeBroker(host, CruiseControl.REST_API_PORT, ((RemoveBrokerOptions.RemoveBrokerOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
default:
future = apiClient.rebalance(host, CruiseControl.REST_API_PORT, ((RebalanceOptions.RebalanceOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
}
return future.map(response -> handleRebalanceResponse(reconciliation, kafkaRebalance, dryrun, response));
}
use of io.strimzi.operator.cluster.operator.resource.cruisecontrol.CruiseControlRebalanceResponse in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperator method requestRebalance.
private Future<MapAndStatus<ConfigMap, KafkaRebalanceStatus>> requestRebalance(Reconciliation reconciliation, String host, CruiseControlApi apiClient, KafkaRebalance kafkaRebalance, boolean dryrun, AbstractRebalanceOptions.AbstractRebalanceOptionsBuilder<?, ?> rebalanceOptionsBuilder, String userTaskID) {
LOGGER.infoCr(reconciliation, "Requesting Cruise Control rebalance [dryrun={}]", dryrun);
rebalanceOptionsBuilder.withVerboseResponse();
if (!dryrun) {
rebalanceOptionsBuilder.withFullRun();
}
// backward compatibility, no mode specified means "full"
KafkaRebalanceMode mode = Optional.ofNullable(kafkaRebalance.getSpec()).map(spec -> spec.getMode()).orElse(KafkaRebalanceMode.FULL);
Future<CruiseControlRebalanceResponse> future;
switch(mode) {
case ADD_BROKERS:
future = apiClient.addBroker(host, CruiseControl.REST_API_PORT, ((AddBrokerOptions.AddBrokerOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
case REMOVE_BROKERS:
future = apiClient.removeBroker(host, CruiseControl.REST_API_PORT, ((RemoveBrokerOptions.RemoveBrokerOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
default:
future = apiClient.rebalance(host, CruiseControl.REST_API_PORT, ((RebalanceOptions.RebalanceOptionsBuilder) rebalanceOptionsBuilder).build(), userTaskID);
break;
}
return future.map(response -> handleRebalanceResponse(reconciliation, kafkaRebalance, dryrun, response));
}
Aggregations