chia7712 commented on code in PR #23821:
URL: https://github.com/apache/kafka/pull/23821#discussion_r4392854083


##########
clients/src/main/java/org/apache/kafka/common/requests/DeleteShareGroupStateRequest.java:
##########
@@ -28,12 +28,21 @@
 import java.util.stream.Collectors;
 
 public class DeleteShareGroupStateRequest extends AbstractRequest {
+
+    private static final short LATEST_VERSION_BEFORE_REQUEST_HEADER_V3 = 0;

Review Comment:
   I prefer avoiding hardcoding if those RPCs are controlled by MV.
   
   MV can return the header version directly and `ApiKeys` can look up the API 
version based on the header version. With both helpers, the hardcoding can be 
stripped out. 
   ```java
   
   public short requestHeaderVersion() {
       return isAtLeast(IBP_4_5_IV0) ? (short) 3 : (short) 2;
   }
   
   public short latestVersionForRequestHeader(short headerVersion) {
       for (short v = latestVersion(); v >= oldestVersion(); v--) {
           if (requestHeaderVersion(v) <= headerVersion) return v;
       }
       throw new UnsupportedVersionException(this + " has no version using 
request header v" + headerVersion + " or lower");
   }
   
   public Builder(WriteShareGroupStateRequestData data, short 
requestHeaderVersion) {
       super(ApiKeys.WRITE_SHARE_GROUP_STATE,
           ApiKeys.WRITE_SHARE_GROUP_STATE.oldestVersion(),
           
ApiKeys.WRITE_SHARE_GROUP_STATE.latestVersionForRequestHeader(requestHeaderVersion));
       this.data = data;
   }
   ```



##########
core/src/main/java/kafka/server/share/ShareCoordinatorMetadataCacheHelperImpl.java:
##########
@@ -176,6 +177,17 @@ public List<Node> getClusterNodes() {
         return List.of();
     }
 
+    @Override
+    public boolean isRequestHeaderV3Supported() {
+        try {
+            MetadataVersion metadataVersion = metadataCache.metadataVersion();
+            return metadataVersion != null && 
metadataVersion.isRequestHeaderV3Supported();

Review Comment:
   `metadataVersion != null` is unnecessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to