KafkaURI { private List<String> parse(String uri) { String[] values = Strings.split(uri, ','); List<String> uris = new ArrayList<>(values.length); for (String value : values) { String result = value.strip(); if (result.indexOf(':') == -1) { uris.add(result + ":9092"); } else { uris.add(result); } } return uris; } KafkaURI(String uri); boolean resolveURI(); @Override String toString(); final List<String> bootstrapURIs; }
@Test void parse() { assertThat(new KafkaURI("kafka-0.kafka").bootstrapURIs) .containsExactly("kafka-0.kafka:9092"); assertThat(new KafkaURI("kafka-0.kafka:9092").bootstrapURIs) .containsExactly("kafka-0.kafka:9092"); assertThat(new KafkaURI("kafka-0.kafka, kafka-1.kafka:9092").bootstrapURIs) .containsExactly("kafka-0.kafka:9092", "kafka-1.kafka:9092"); }