-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
prevent npe on mismatch between number of kafka partitions and task count #5139
Conversation
pjain1
commented
Dec 5, 2017
👍 |
@@ -2117,7 +2117,7 @@ private void updateLatestOffsetsFromKafka() | |||
&& latestOffsetsFromKafka.get(e.getKey()) != null | |||
&& e.getValue() != null | |||
? latestOffsetsFromKafka.get(e.getKey()) - e.getValue() | |||
: null | |||
: Integer.MIN_VALUE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe is the below better because we don't have to add unnecessary lag values?
private Map<Integer, Long> getLagPerPartition(Map<Integer, Long> currentOffsets)
{
if (latestOffsetsFromKafka == null) {
return ImmutableMap.of();
}
return currentOffsets
.entrySet()
.stream()
.filter(e -> latestOffsetsFromKafka.get(e.getKey()) != null && e.getValue() != null)
.collect(
Collectors.toMap(
Map.Entry::getKey,
e -> latestOffsetsFromKafka.get(e.getKey()) - e.getValue()
)
);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't wanted to filter so that its visible that there is mismatch between task count and number of available Kafka partitions. Currently, whenever total lag is calculated, x -> Math.max(x, 0)
is used so setting lag to Integer.MIN_VALUE
won't add to the total.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, if you prefer this then we can do this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both looks good to me. If you think the current patch is better to check there is mismatch between task count and number of partitions, please go for it.
* Kafka Index Task that supports Incremental handoffs apache#4815 * prevent NPE from supressing actual exception (apache#5146) * prevent npe on mismatch between number of kafka partitions and task count (apache#5139) * Throw away rows with timestamps beyond long bounds in kafka indexing (apache#5215) (apache#5232) * Fix state check bug in Kafka Index Task (apache#5204) (apache#5248)