Search in sources :

Example 11 with KafkaRebalanceBuilder

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();
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition) KafkaRebalanceStatus(io.strimzi.api.kafka.model.status.KafkaRebalanceStatus) KafkaRebalanceBuilder(io.strimzi.api.kafka.model.KafkaRebalanceBuilder)

Example 12 with KafkaRebalanceBuilder

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();
}
Also used : HashMap(java.util.HashMap) KafkaRebalanceBuilder(io.strimzi.api.kafka.model.KafkaRebalanceBuilder)

Aggregations

KafkaRebalanceBuilder (io.strimzi.api.kafka.model.KafkaRebalanceBuilder)12 Condition (io.strimzi.api.kafka.model.status.Condition)8 KafkaRebalance (io.strimzi.api.kafka.model.KafkaRebalance)6 KafkaRebalanceStatus (io.strimzi.api.kafka.model.status.KafkaRebalanceStatus)6 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)4 Secret (io.fabric8.kubernetes.api.model.Secret)4 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)4 KafkaList (io.strimzi.api.kafka.KafkaList)4 KafkaRebalanceList (io.strimzi.api.kafka.KafkaRebalanceList)4 CruiseControlResources (io.strimzi.api.kafka.model.CruiseControlResources)4 Kafka (io.strimzi.api.kafka.model.Kafka)4 KafkaRebalanceSpec (io.strimzi.api.kafka.model.KafkaRebalanceSpec)4 KafkaRebalanceAnnotation (io.strimzi.api.kafka.model.balancing.KafkaRebalanceAnnotation)4 KafkaRebalanceState (io.strimzi.api.kafka.model.balancing.KafkaRebalanceState)4 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)4 ClusterOperatorConfig (io.strimzi.operator.cluster.ClusterOperatorConfig)4 CruiseControl (io.strimzi.operator.cluster.model.CruiseControl)4 InvalidResourceException (io.strimzi.operator.cluster.model.InvalidResourceException)4 NoSuchResourceException (io.strimzi.operator.cluster.model.NoSuchResourceException)4 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)4