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

KAFKA-3711: Ensure a RecordingMap is passed to configured instances #1479

Closed
wants to merge 4 commits into from

Conversation

jklukas
Copy link
Contributor

@jklukas jklukas commented Jun 7, 2016

See https://issues.apache.org/jira/browse/KAFKA-3711

I've tested locally that this change does indeed resolve the warning I mention in the ticket:

org.apache.kafka.clients.consumer.ConsumerConfig: The configuration metric.dropwizard.registry = kafka-metrics was supplied but isn't a known config.

where metric.dropwizard.registry is a configuration value defined in a custom MetricReporter (https://github.com/SimpleFinance/kafka-dropwizard-reporter).

With this change, the above warning no longer appears, as @ewencp predicted.

This contribution is my original work and I license the work to the project under the project's open source license.

@jklukas
Copy link
Contributor Author

jklukas commented Jun 7, 2016

cc @ijuma @guozhangwang

@ijuma
Copy link
Contributor

ijuma commented Jun 7, 2016

LGTM. I'll let @ewencp check as well since he suggested the change.

@ewencp
Copy link
Contributor

ewencp commented Jun 7, 2016

This seems fine for the specific issue. A few things:

  1. I wonder if we should just make this.originals a RecordingMap to get rid of this issue entirely -- any use of this.originals would have the right behavior.
  2. Unit test?
  3. I think originalsWithPrefix may not work correctly still. I think for that case, the implementation of RecordingMap needs to take the prefix and add it to the key when recording each used key.

3 could easily be left to a separate JIRA (Connect is the only user of this at the moment, although increasingly I think we should be adopting the approach to avoid a lot of this mess of shared namespaces and trying to track shared usage of configs).

@ijuma
Copy link
Contributor

ijuma commented Jun 7, 2016

@ewencp, the issue with assigning RecordingMap to originals is that we may mark a config as used inadvertently (e.g. in the unused() method). But it looks like the distinction between originals and originals() is too subtle and error-prone. Perhaps, we should have a field or method with a different name instead of originals() (recordingOriginals?).

Good catch about originalsWithPrefix.

@ewencp
Copy link
Contributor

ewencp commented Jun 7, 2016

@ijuma Ah, that makes sense. I'm actually ok with it as is, we just have to take care when adding anything to this class. It's relatively low churn these days, so it's not a huge concern to me. However, we definitely should have a unit test.

@jklukas
Copy link
Contributor Author

jklukas commented Jun 7, 2016

I will work on adding a unit test. I'll also take a look at originalsWithPrefix.

@jklukas
Copy link
Contributor Author

jklukas commented Jun 8, 2016

This should be ready for review again. Pushed two commits that add tests and allow RecordingMap to handle a prefix.

if (key instanceof String)
ignore((String) key);
if (key instanceof String) {
String keyWithPrefix = prefix + key;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably avoid string concatenation if prefix.isEmpty (since it's the common case).

keyWithPrefix = (String) key;
} else {
keyWithPrefix = prefix + key;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now check prefix.isEmpty() here to avoid concatentation in most cases and save a String allocation, as suggested by @ijuma

@ewencp
Copy link
Contributor

ewencp commented Jun 8, 2016

LGTM

@asfgit asfgit closed this in eb6f04a Jun 8, 2016
@guozhangwang
Copy link
Contributor

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants