Skip to content
Closed
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 @@ -32,12 +32,12 @@ public RocksDBMetricsRecordingTrigger(final Time time) {

public void addMetricsRecorder(final RocksDBMetricsRecorder metricsRecorder) {
final String metricsRecorderName = metricsRecorderName(metricsRecorder);
if (metricsRecordersToTrigger.containsKey(metricsRecorderName)) {
final RocksDBMetricsRecorder existingRocksDBMetricsRecorder = metricsRecordersToTrigger.putIfAbsent(metricsRecorderName, metricsRecorder);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a nice improvement in readability, but are we certain it's necessary? I commented on the change to the plugin scanning logic in Connect because I'm familiar with that part of the code base; I don't have the same familiarity with Streams, though.

I think it's fine to merge this change, but if this method isn't intended to be invoked concurrently, we should modify the PR title so that the commit message doesn't imply this is a bug fix and instead recognizes it as a cosmetic improvement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @C0urante here, if the method isn't meant to be invoked in a concurrent situation then we should either revert to the original containsKey OR add a comment along the lines of "Currently this code isn't called in a concurrent situation"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for your code review folks. On deeper analysis, it doesn't look like that this code will be invoked by multiple threads. I will discard this PR now and I thank you again for looking into this PR.

if (existingRocksDBMetricsRecorder != null) {
throw new IllegalStateException("RocksDB metrics recorder for store \"" + metricsRecorder.storeName() +
"\" of task " + metricsRecorder.taskId().toString() + " has already been added. "
+ "This is a bug in Kafka Streams.");
}
metricsRecordersToTrigger.put(metricsRecorderName, metricsRecorder);
}

public void removeMetricsRecorder(final RocksDBMetricsRecorder metricsRecorder) {
Expand Down