Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support set client.id with Zone ID for Kafka driver #424

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@

public class KafkaBenchmarkDriver implements BenchmarkDriver {

private static final String ZONE_ID_CONFIG = "zone.id";
private static final String ZONE_ID_TEMPLATE = "{zone.id}";
private static final String KAFKA_CLIENT_ID = "client.id";
private Config config;

private List<BenchmarkProducer> producers = Collections.synchronizedList(new ArrayList<>());
Expand All @@ -63,6 +66,13 @@ public void initialize(File configurationFile, StatsLogger statsLogger) throws I
Properties commonProperties = new Properties();
commonProperties.load(new StringReader(config.commonConfig));

if (commonProperties.containsKey(KAFKA_CLIENT_ID)) {
commonProperties.put(
KAFKA_CLIENT_ID,
applyZoneId(
commonProperties.getProperty(KAFKA_CLIENT_ID), System.getProperty(ZONE_ID_CONFIG)));
}

producerProperties = new Properties();
commonProperties.forEach((key, value) -> producerProperties.put(key, value));
producerProperties.load(new StringReader(config.producerConfig));
Expand Down Expand Up @@ -151,6 +161,10 @@ public void close() throws Exception {
admin.close();
}

private static String applyZoneId(String clientId, String zoneId) {
return clientId.replace(ZONE_ID_TEMPLATE, zoneId);
}

private static final ObjectMapper mapper =
new ObjectMapper(new YAMLFactory())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand Down
Loading