All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.consumers.config.ZookeeperClustersProperties Maven / Gradle / Ivy

There is a newer version: 2.8.0
Show newest version
package pl.allegro.tech.hermes.consumers.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import pl.allegro.tech.hermes.infrastructure.dc.DatacenterNameProvider;

import java.util.ArrayList;
import java.util.List;

@ConfigurationProperties(prefix = "consumer.zookeeper")
public class ZookeeperClustersProperties {

    private List clusters = new ArrayList<>();

    public List getClusters() {
        return clusters;
    }

    public void setClusters(List clusters) {
        this.clusters = clusters;
    }

    public ZookeeperProperties toZookeeperProperties(DatacenterNameProvider datacenterNameProvider) {
        return this.clusters
                .stream()
                .filter(cluster -> cluster.getDatacenter().equals(datacenterNameProvider.getDatacenterName()))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(
                        "No properties for datacenter: " + datacenterNameProvider.getDatacenterName() + " defined."));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy