Skip to content

Conversation

@jeqo
Copy link
Contributor

@jeqo jeqo commented Mar 30, 2025

For further flexibility, it may be useful to differentiate client ids when passing a zone id.

Currently, if a zone id variable is needed, it needs to be in common configurations, forcing both producer and consumer to have the same values (with different zones).

This proposal extends the same parsing to client ids from producer and consumers; adds some unit tests; and documents this feature.

@jeqo jeqo force-pushed the kafka-client-id-per-prod-cons branch from 0a00002 to 874db8a Compare March 30, 2025 21:18
Copy link

@OneCricketeer OneCricketeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observations


When running workers, pass the `zone.id`:

```bash

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit KAFKA_OPTS

/opt/benchmark/bin/benchmark-worker
```

Then pass the `client.id` template:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use something like envsubst

private Properties topicProperties;
private Properties producerProperties;
private Properties consumerProperties;
// Visible for testing
Copy link

@OneCricketeer OneCricketeer Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a Hashmap/table + enum for the three types

}

producerProperties = new Properties();
commonProperties.forEach((key, value) -> producerProperties.put(key, value));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this seems inefficient

producerProperties.load(new StringReader(config.producerConfig));

if (producerProperties.containsKey(KAFKA_CLIENT_ID)) {
producerProperties.put(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a putIfAbsent inversion?


try (KafkaBenchmarkDriver driver = new KafkaBenchmarkDriver()) {
// When initializing kafka driver
Files.write(configPath, KafkaBenchmarkDriver.mapper.writeValueAsBytes(config));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a ByteArray Stream rather than a file


// Then
if (producerClientId != null) {
assertThat(driver.producerProperties).containsEntry("client.id", producerClientId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert against CommonConfig constants not magic string

driver.initialize(configPath.toFile(), null);

// Then
if (producerClientId != null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Optional types are better than nullable Objects

} else {
assertThat(driver.producerProperties).doesNotContainKey("client.id");
}
if (consumerClientId != null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should assert nullability based on parameterized test order , otherwise this is just lazy testing

assertThat(driver.producerProperties).doesNotContainKey("client.id");
}
if (consumerClientId != null) {
assertThat(driver.consumerProperties).containsEntry("client.id", consumerClientId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume containsEntry does the key check short circuit?

@stale
Copy link

stale bot commented May 31, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 5 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 31, 2025
@stale stale bot closed this Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants