use of io.strimzi.api.kafka.model.KafkaRebalanceBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceStateMachineTest method createKafkaRebalance.
/**
* Creates an example {@link KafkaRebalanceBuilder} instance using the supplied state parameters.
*
* @param currentState The current state of the resource before being passed to computeNextStatus.
* @param currentStatusSessionID The user task ID attached to the current KafkaRebalance resource. Can be null.
* @param userAnnotation An annotation to be applied after the reconcile has started, for example "approve" or "stop".
* @param rebalanceSpec A custom rebalance specification. If null a blank spec will be used.
* @return A KafkaRebalance instance configured with the supplied parameters.
*/
private KafkaRebalance createKafkaRebalance(KafkaRebalanceState currentState, String currentStatusSessionID, String userAnnotation, KafkaRebalanceSpec rebalanceSpec) {
KafkaRebalanceBuilder kafkaRebalanceBuilder = new KafkaRebalanceBuilder().editOrNewMetadata().withName(RESOURCE_NAME).withNamespace(CLUSTER_NAMESPACE).withLabels(Collections.singletonMap(Labels.STRIMZI_CLUSTER_LABEL, CLUSTER_NAME)).withAnnotations(Collections.singletonMap(Annotations.ANNO_STRIMZI_IO_REBALANCE, userAnnotation == null ? "none" : userAnnotation)).endMetadata().withSpec(rebalanceSpec);
// there is no actual status and related condition when a KafkaRebalance is just created
if (currentState != KafkaRebalanceState.New) {
Condition currentRebalanceCondition = new Condition();
currentRebalanceCondition.setType(currentState.toString());
currentRebalanceCondition.setStatus("True");
KafkaRebalanceStatus currentStatus = new KafkaRebalanceStatus();
currentStatus.setConditions(Collections.singletonList(currentRebalanceCondition));
currentStatus.setSessionId(currentStatusSessionID);
kafkaRebalanceBuilder.withStatus(currentStatus);
}
return kafkaRebalanceBuilder.build();
}
use of io.strimzi.api.kafka.model.KafkaRebalanceBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceTemplates method defaultKafkaRebalance.
private static KafkaRebalanceBuilder defaultKafkaRebalance(KafkaRebalance kafkaRebalance, String name) {
Map<String, String> kafkaRebalanceLabels = new HashMap<>();
kafkaRebalanceLabels.put("strimzi.io/cluster", name);
return new KafkaRebalanceBuilder(kafkaRebalance).editMetadata().withName(name).withNamespace(ResourceManager.kubeClient().getNamespace()).withLabels(kafkaRebalanceLabels).endMetadata();
}
Aggregations