Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2014c0

Browse files
authoredMar 4, 2025
MINOR: Small refactor in GroupMetadataManager (apache#19090)
The code in GroupMetadataManager to request metadata refresh got pretty ugly with the addition of share and stream groups. It seems preferable to put the method in the base class. Reviewers: Andrew Schofield <[email protected]>
1 parent 1df4a42 commit c2014c0

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed
 

‎group-coordinator/src/main/java/org/apache/kafka/coordinator/group/Group.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,9 @@ void validateOffsetFetch(
195195
* @return The number of members.
196196
*/
197197
int numMembers();
198+
199+
/**
200+
* Requests a metadata refresh.
201+
*/
202+
void requestMetadataRefresh();
198203
}

‎group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,11 +4786,8 @@ public void onNewMetadataImage(MetadataImage newImage, MetadataDelta delta) {
47864786
});
47874787
allGroupIds.forEach(groupId -> {
47884788
Group group = groups.get(groupId);
4789-
if (group != null && (group.type() == CONSUMER || group.type() == SHARE)) {
4790-
((ModernGroup<?>) group).requestMetadataRefresh();
4791-
}
4792-
if (group != null && (group.type() == STREAMS)) {
4793-
((StreamsGroup) group).requestMetadataRefresh();
4789+
if (group != null) {
4790+
group.requestMetadataRefresh();
47944791
}
47954792
});
47964793
}

‎group-coordinator/src/main/java/org/apache/kafka/coordinator/group/classic/ClassicGroup.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ public int numMembers() {
342342
return members.size();
343343
}
344344

345+
/**
346+
* Requests a metadata refresh.
347+
*/
348+
@Override
349+
public void requestMetadataRefresh() {
350+
// This does not apply to classic groups.
351+
}
352+
345353
/**
346354
* Used to identify whether the given member is the leader of this group.
347355
*

‎group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/ModernGroup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ public void setMetadataRefreshDeadline(
414414
/**
415415
* Requests a metadata refresh.
416416
*/
417+
@Override
417418
public void requestMetadataRefresh() {
418419
this.metadataRefreshDeadline = DeadlineAndEpoch.EMPTY;
419420
}

‎group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ public void setMetadataRefreshDeadline(
602602
/**
603603
* Requests a metadata refresh.
604604
*/
605+
@Override
605606
public void requestMetadataRefresh() {
606607
this.metadataRefreshDeadline = DeadlineAndEpoch.EMPTY;
607608
}

0 commit comments

Comments
 (0)
Please sign in to comment.