Groovy web console

subscribe to the feed Subscribe
to this
site

intRange

Published 4 weeks ago by Roy
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def get_kafka_host(cluster_name, env) {
    def cluster_short_name = cluster_name.replaceFirst(/^data-infra-emr-/, '').replaceFirst("-$env", '')
    def kafka_hot_cluster = ["hot_reindex", "transformations", "aggregations_hot_reindex"]

    String kafka_hosts_prefix = "kafka"
    if (kafka_hot_cluster.contains(cluster_short_name)) {
        kafka_hosts_prefix = "kafka-hot-realtime-index"
    } else if (cluster_short_name == "cold_reindex") {
        kafka_hosts_prefix = "kafka-cold-index"
    }

    String kafka_hosts = (1..5).stream().map{ i -> "$kafka_hosts_prefix-$env-$i" }.collect().join(",")
    return kafka_hosts
}

get_kafka_host("data-infra-emr-views-stg", "stg")