-
Notifications
You must be signed in to change notification settings - Fork 14.6k
MINOR: Cleanups in coordinator-common/group-coordinator #20097
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
Conversation
341e247
to
1d6f7b5
Compare
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.
Overall, LGTM. Left one minor comment.
@@ -36,7 +36,7 @@ | |||
public record TopologyMetadata(MetadataImage metadataImage, SortedMap<String, ConfiguredSubtopology> subtopologyMap) implements TopologyDescriber { | |||
|
|||
public TopologyMetadata { | |||
metadataImage = Objects.requireNonNull(metadataImage); | |||
Objects.requireNonNull(metadataImage); | |||
subtopologyMap = Objects.requireNonNull(Collections.unmodifiableSortedMap(subtopologyMap)); |
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.
Nitpick. The same applies to line36 in StreamsGroupHeartbeatResult.java
.
subtopologyMap = Objects.requireNonNull(Collections.unmodifiableSortedMap(subtopologyMap)); | |
subtopologyMap = Collections.unmodifiableSortedMap(Objects.requireNonNull(subtopologyMap)); |
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'm not sure I understand your comment. Can you clarify what you mean?
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.
If the passed subtopologyMap
is null
Current: Collections.unmodifiableSortedMap throws NPE (so Objects.requireNonNull never takes effect).
After: Objects.requireNonNull throws NPE.
Also, this results in a different stack trace if NPE.
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.
Good point, done
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.
Thanks @mimaison for this patch, a little comment
/** | ||
* @return The base timestamp. | ||
*/ | ||
@Override | ||
public Function<OffsetAndMetadata, Long> baseTimestamp() { | ||
return this.baseTimestamp; | ||
} |
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.
The override method also can be removed.
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.
Right, done
this.partitions = Objects.requireNonNull(partitions); | ||
public record MemberAssignmentImpl(Map<Uuid, Set<Integer>> partitions) implements MemberAssignment { | ||
public MemberAssignmentImpl { | ||
Objects.requireNonNull(partitions); |
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.
Should we wrap the partitions
with Collections.unmodifiableMap
?
This could ensure the consistency of hashCode
.
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.
Yup I added that
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.
Since the PR does some cleanup in GroupMetadataManagerTest
, could we also fix following items in this PR? Thanks
- Change to
assertEquals(Errors.LEADER_NOT_AVAILABLE, appendGroupMetadataErrorToResponseError(Errors.LEADER_NOT_AVAILABLE));
. I think the assertion would like to testappendGroupMetadataErrorToResponseError
can return inputappendError
if error is non-matched.
- Wrong orders.
- Unnecessary
;
@@ -219,7 +219,7 @@ public static Map<Uuid, Set<Integer>> assignmentFromTopicPartitions( | |||
) { | |||
return topicPartitionsList.stream().collect(Collectors.toMap( | |||
ConsumerGroupCurrentMemberAssignmentValue.TopicPartitions::topicId, | |||
topicPartitions -> Collections.unmodifiableSet(new HashSet<>(topicPartitions.partitions())))); | |||
topicPartitions -> Collections.unmodifiableSet(new HashSet<>(topicPartitions.partitions())))); |
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.
nit: Do we need the extra indentation? since L221 and 222 are two parameters of Collectors.toMap
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.
Fixed
7c15597
to
bd91f38
Compare
Thanks @FrankYang0529 for the review. I pushed an update addressing the issues you found. |
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.
LGTM. Thanks for the patch.
public final String key; | ||
public final CoordinatorResult<Void, T> result; | ||
|
||
public record ExecutorResult<T>(String key, CoordinatorResult<Void, T> result) { |
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.
Well done thanks. Kind of hard to review as its entangled, but thats how its done, no offence given. Its not ensured that these patterns wont (re)occur anywhere else, making the whole storing ongoing. Rewrite has the ability to automate this:
Hope this helps, thanks. |
- Use `record` where possible - Use enhanced `switch` - Tweak a bunch of assertions Reviewers: Yung <[email protected]>, TengYao Chi <[email protected]>, Ken Huang <[email protected]>, Dongnuo Lyu <[email protected]>, PoAn Yang <[email protected]>
- Use `record` where possible - Use enhanced `switch` - Tweak a bunch of assertions Reviewers: Yung <[email protected]>, TengYao Chi <[email protected]>, Ken Huang <[email protected]>, Dongnuo Lyu <[email protected]>, PoAn Yang <[email protected]>
record
where possibleswitch
Reviewers: Yung [email protected], TengYao Chi
[email protected], Ken Huang [email protected], Dongnuo Lyu
[email protected], PoAn Yang [email protected]