MINOR: Cleanups in coordinator-common/group-coordinator#20097
MINOR: Cleanups in coordinator-common/group-coordinator#20097FrankYang0529 merged 3 commits intoapache:trunkfrom
Conversation
341e247 to
1d6f7b5
Compare
Yunyung
left a comment
There was a problem hiding this comment.
Overall, LGTM. Left one minor comment.
| public TopologyMetadata { | ||
| metadataImage = Objects.requireNonNull(metadataImage); | ||
| Objects.requireNonNull(metadataImage); | ||
| subtopologyMap = Objects.requireNonNull(Collections.unmodifiableSortedMap(subtopologyMap)); |
There was a problem hiding this comment.
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.
I'm not sure I understand your comment. Can you clarify what you mean?
There was a problem hiding this comment.
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.
| /** | ||
| * @return The base timestamp. | ||
| */ | ||
| @Override | ||
| public Function<OffsetAndMetadata, Long> baseTimestamp() { | ||
| return this.baseTimestamp; | ||
| } |
There was a problem hiding this comment.
The override method also can be removed.
| 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.
Should we wrap the partitions with Collections.unmodifiableMap?
This could ensure the consistency of hashCode.
FrankYang0529
left a comment
There was a problem hiding this comment.
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 testappendGroupMetadataErrorToResponseErrorcan return inputappendErrorif error is non-matched.
- Wrong orders.
- Unnecessary
;
| 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.
nit: Do we need the extra indentation? since L221 and 222 are two parameters of Collectors.toMap
7c15597 to
bd91f38
Compare
|
Thanks @FrankYang0529 for the review. I pushed an update addressing the issues you found. |
FrankYang0529
left a comment
There was a problem hiding this comment.
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.
|
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]>
The server-side assignors are designed to re-use the previous assignment maps where possible and clone them for modification lazily. apache#20097 introduced a bug where the assignments would always be re-wrapped in an unmodifiable map and so we would end up cloning them repeatedly in the assignors when multiple changes need to be made to a member assignment. Fix the bug by removing the unmodifiable map wrapping.
The server-side assignors are designed to re-use the previous assignment maps where possible and clone them for modification lazily. apache#20097 introduced a bug where the assignments would always be re-wrapped in an unmodifiable map and so we would end up cloning them repeatedly in the assignors when multiple changes need to be made to a member assignment. Fix the bug by removing the unmodifiable map wrapping.
) The server-side assignors are designed to re-use the previous assignment maps where possible and clone them for modification lazily. #20097 introduced a bug where the assignments would always be re-wrapped in an unmodifiable map and so we would end up cloning them repeatedly in the assignors when multiple changes need to be made to a member assignment. Fix the bug by removing the unmodifiable map wrapping. Reviewers: David Jacot <[email protected]>
) The server-side assignors are designed to re-use the previous assignment maps where possible and clone them for modification lazily. #20097 introduced a bug where the assignments would always be re-wrapped in an unmodifiable map and so we would end up cloning them repeatedly in the assignors when multiple changes need to be made to a member assignment. Fix the bug by removing the unmodifiable map wrapping. Reviewers: David Jacot <[email protected]>
…che#21058) The server-side assignors are designed to re-use the previous assignment maps where possible and clone them for modification lazily. apache#20097 introduced a bug where the assignments would always be re-wrapped in an unmodifiable map and so we would end up cloning them repeatedly in the assignors when multiple changes need to be made to a member assignment. Fix the bug by removing the unmodifiable map wrapping. Reviewers: David Jacot <[email protected]>
recordwhere possibleswitchReviewers: Yung [email protected], TengYao Chi
[email protected], Ken Huang [email protected], Dongnuo Lyu
[email protected], PoAn Yang [email protected]