Search in sources :

Example 1 with GenericKafkaListenerConfiguration

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfiguration in project strimzi by strimzi.

the class ListenersValidator method validateIngress.

/**
 * Validates that Ingress type listener has the right host configurations
 *
 * @param errors    List where any found errors will be added
 * @param replicas  Number of Kafka replicas
 * @param listener  Listener which needs to be validated
 */
private static void validateIngress(Set<String> errors, int replicas, GenericKafkaListener listener) {
    if (listener.getConfiguration() != null) {
        GenericKafkaListenerConfiguration conf = listener.getConfiguration();
        if (conf.getBootstrap() == null || conf.getBootstrap().getHost() == null) {
            errors.add("listener " + listener.getName() + " is missing a bootstrap host name which is required for Ingress based listeners");
        }
        if (conf.getBrokers() != null) {
            for (int i = 0; i < replicas; i++) {
                final int id = i;
                GenericKafkaListenerConfigurationBroker broker = conf.getBrokers().stream().filter(b -> b.getBroker() == id).findFirst().orElse(null);
                if (broker == null || broker.getHost() == null) {
                    errors.add("listener " + listener.getName() + " is missing a broker host name for broker with ID " + i + " which is required for Ingress based listeners");
                }
            }
        } else {
            errors.add("listener " + listener.getName() + " is missing a broker configuration with host names which is required for Ingress based listeners");
        }
    } else {
        errors.add("listener " + listener.getName() + " is missing a configuration with host names which is required for Ingress based listeners");
    }
}
Also used : GenericKafkaListenerConfiguration(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfiguration) GenericKafkaListenerConfigurationBroker(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker)

Example 2 with GenericKafkaListenerConfiguration

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfiguration in project strimzi-kafka-operator by strimzi.

the class ListenersValidator method validateIngress.

/**
 * Validates that Ingress type listener has the right host configurations
 *
 * @param errors    List where any found errors will be added
 * @param replicas  Number of Kafka replicas
 * @param listener  Listener which needs to be validated
 */
private static void validateIngress(Set<String> errors, int replicas, GenericKafkaListener listener) {
    if (listener.getConfiguration() != null) {
        GenericKafkaListenerConfiguration conf = listener.getConfiguration();
        if (conf.getBootstrap() == null || conf.getBootstrap().getHost() == null) {
            errors.add("listener " + listener.getName() + " is missing a bootstrap host name which is required for Ingress based listeners");
        }
        if (conf.getBrokers() != null) {
            for (int i = 0; i < replicas; i++) {
                final int id = i;
                GenericKafkaListenerConfigurationBroker broker = conf.getBrokers().stream().filter(b -> b.getBroker() == id).findFirst().orElse(null);
                if (broker == null || broker.getHost() == null) {
                    errors.add("listener " + listener.getName() + " is missing a broker host name for broker with ID " + i + " which is required for Ingress based listeners");
                }
            }
        } else {
            errors.add("listener " + listener.getName() + " is missing a broker configuration with host names which is required for Ingress based listeners");
        }
    } else {
        errors.add("listener " + listener.getName() + " is missing a configuration with host names which is required for Ingress based listeners");
    }
}
Also used : GenericKafkaListenerConfiguration(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfiguration) GenericKafkaListenerConfigurationBroker(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker)

Aggregations

GenericKafkaListenerConfiguration (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfiguration)2 GenericKafkaListenerConfigurationBroker (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker)2