Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-31 Thread via GitHub


frankvicky commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1938170752


##
raft/src/main/java/org/apache/kafka/raft/utils/DescribeQuorumRpc.java:
##
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.DescribeQuorumRequestData;
+import org.apache.kafka.common.message.DescribeQuorumResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.LeaderState;
+import org.apache.kafka.raft.LogOffsetMetadata;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class DescribeQuorumRpc {
+public static DescribeQuorumRequestData singletonDescribeQuorumRequest(
+TopicPartition topicPartition
+) {
+return new DescribeQuorumRequestData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+)
+)
+)
+);
+}
+
+public static DescribeQuorumResponseData singletonDescribeQuorumResponse(
+short apiVersion,
+TopicPartition topicPartition,
+int leaderId,
+int leaderEpoch,
+long highWatermark,
+Collection voters,
+Collection observers,
+long currentTimeMs
+) {
+DescribeQuorumResponseData response = new DescribeQuorumResponseData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumResponseData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumResponseData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+.setErrorCode(Errors.NONE.code())
+.setLeaderId(leaderId)
+.setLeaderEpoch(leaderEpoch)
+.setHighWatermark(highWatermark)
+
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
+.setObservers(toReplicaStates(apiVersion, 
leaderId, observers, currentTimeMs));

Review Comment:
   I will take a look 😺 



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-31 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1937578663


##
raft/src/main/java/org/apache/kafka/raft/utils/DescribeQuorumRpc.java:
##
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.DescribeQuorumRequestData;
+import org.apache.kafka.common.message.DescribeQuorumResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.LeaderState;
+import org.apache.kafka.raft.LogOffsetMetadata;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class DescribeQuorumRpc {
+public static DescribeQuorumRequestData singletonDescribeQuorumRequest(
+TopicPartition topicPartition
+) {
+return new DescribeQuorumRequestData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+)
+)
+)
+);
+}
+
+public static DescribeQuorumResponseData singletonDescribeQuorumResponse(
+short apiVersion,
+TopicPartition topicPartition,
+int leaderId,
+int leaderEpoch,
+long highWatermark,
+Collection voters,
+Collection observers,
+long currentTimeMs
+) {
+DescribeQuorumResponseData response = new DescribeQuorumResponseData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumResponseData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumResponseData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+.setErrorCode(Errors.NONE.code())
+.setLeaderId(leaderId)
+.setLeaderEpoch(leaderEpoch)
+.setHighWatermark(highWatermark)
+
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
+.setObservers(toReplicaStates(apiVersion, 
leaderId, observers, currentTimeMs));

Review Comment:
   style nit: I know this was carried over from the old code, but maybe better 
to have each closing parenthesis on its own new line
   
   (there are a few other spots in the PR which could use this too)



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-31 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1937578663


##
raft/src/main/java/org/apache/kafka/raft/utils/DescribeQuorumRpc.java:
##
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.DescribeQuorumRequestData;
+import org.apache.kafka.common.message.DescribeQuorumResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.LeaderState;
+import org.apache.kafka.raft.LogOffsetMetadata;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class DescribeQuorumRpc {
+public static DescribeQuorumRequestData singletonDescribeQuorumRequest(
+TopicPartition topicPartition
+) {
+return new DescribeQuorumRequestData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+)
+)
+)
+);
+}
+
+public static DescribeQuorumResponseData singletonDescribeQuorumResponse(
+short apiVersion,
+TopicPartition topicPartition,
+int leaderId,
+int leaderEpoch,
+long highWatermark,
+Collection voters,
+Collection observers,
+long currentTimeMs
+) {
+DescribeQuorumResponseData response = new DescribeQuorumResponseData()
+.setTopics(
+Collections.singletonList(
+new DescribeQuorumResponseData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new DescribeQuorumResponseData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+.setErrorCode(Errors.NONE.code())
+.setLeaderId(leaderId)
+.setLeaderEpoch(leaderEpoch)
+.setHighWatermark(highWatermark)
+
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
+.setObservers(toReplicaStates(apiVersion, 
leaderId, observers, currentTimeMs));

Review Comment:
   style nit: I know this was carried over from the old code, but maybe better 
to have each closing parenthesis on its own new line



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-13 Thread via GitHub


frankvicky commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1913976839


##
raft/src/main/java/org/apache/kafka/raft/utils/BeginQuorumEpochRpc.java:
##
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.BeginQuorumEpochRequestData;
+import org.apache.kafka.common.message.BeginQuorumEpochResponseData;
+import org.apache.kafka.common.network.ListenerName;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.Endpoints;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.Optional;
+
+
+public class BeginQuorumEpochRpc {
+public static BeginQuorumEpochRequestData singletonBeginQuorumEpochRequest(
+TopicPartition topicPartition,
+String clusterId,
+int leaderEpoch,
+int leaderId,
+Endpoints leaderEndpoints,
+ReplicaKey voterKey
+) {
+return new BeginQuorumEpochRequestData()
+.setClusterId(clusterId)
+.setVoterId(voterKey.id())
+.setTopics(
+Collections.singletonList(
+new BeginQuorumEpochRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new 
BeginQuorumEpochRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+
.setLeaderEpoch(leaderEpoch)
+
.setLeaderId(leaderId)
+
.setVoterDirectoryId(voterKey.directoryId().orElse(ReplicaKey.NO_DIRECTORY_ID))
+)
+)
+)
+)
+
.setLeaderEndpoints(leaderEndpoints.toBeginQuorumEpochRequest());
+}
+
+public static BeginQuorumEpochResponseData 
singletonBeginQuorumEpochResponse(
+ListenerName listenerName,
+short apiVersion,
+Errors topLevelError,
+TopicPartition topicPartition,
+Errors partitionLevelError,
+int leaderEpoch,
+int leaderId,
+Endpoints endpoints
+) {
+BeginQuorumEpochResponseData response = new 
BeginQuorumEpochResponseData()
+.setErrorCode(topLevelError.code())
+.setTopics(
+Collections.singletonList(
+new BeginQuorumEpochResponseData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new 
BeginQuorumEpochResponseData.PartitionData()
+
.setErrorCode(partitionLevelError.code())
+
.setLeaderId(leaderId)
+
.setLeaderEpoch(leaderEpoch)
+)
+)
+)
+);
+
+if (apiVersion >= 1) {
+Optional address = 
endpoints.address(listenerName);
+if (address.isPresent() && leaderId >= 0) {
+// Populate the node endpoints
+BeginQuorumEpochResponseData.NodeEndpointCollection 
nodeEndpoints =
+new 
BeginQuorumEpochResponseData.NodeEndpointCollection(1);
+nod

Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-13 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1913875681


##
raft/src/main/java/org/apache/kafka/raft/utils/DescribeQuorumRpc.java:
##
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.DescribeQuorumRequestData;
+import org.apache.kafka.common.message.DescribeQuorumResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.LeaderState;
+import org.apache.kafka.raft.LogOffsetMetadata;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class DescribeQuorumRpc {
+public static DescribeQuorumRequestData singletonDescribeQuorumRequest(
+TopicPartition topicPartition
+) {
+return new DescribeQuorumRequestData()
+.setTopics(

Review Comment:
   looks like these are all 8 vs 4 spaces



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2025-01-13 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1913874958


##
raft/src/main/java/org/apache/kafka/raft/utils/BeginQuorumEpochRpc.java:
##
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.message.BeginQuorumEpochRequestData;
+import org.apache.kafka.common.message.BeginQuorumEpochResponseData;
+import org.apache.kafka.common.network.ListenerName;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.Endpoints;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.Optional;
+
+
+public class BeginQuorumEpochRpc {
+public static BeginQuorumEpochRequestData singletonBeginQuorumEpochRequest(
+TopicPartition topicPartition,
+String clusterId,
+int leaderEpoch,
+int leaderId,
+Endpoints leaderEndpoints,
+ReplicaKey voterKey
+) {
+return new BeginQuorumEpochRequestData()
+.setClusterId(clusterId)
+.setVoterId(voterKey.id())
+.setTopics(
+Collections.singletonList(
+new BeginQuorumEpochRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new 
BeginQuorumEpochRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+
.setLeaderEpoch(leaderEpoch)
+
.setLeaderId(leaderId)
+
.setVoterDirectoryId(voterKey.directoryId().orElse(ReplicaKey.NO_DIRECTORY_ID))
+)
+)
+)
+)
+
.setLeaderEndpoints(leaderEndpoints.toBeginQuorumEpochRequest());
+}
+
+public static BeginQuorumEpochResponseData 
singletonBeginQuorumEpochResponse(
+ListenerName listenerName,
+short apiVersion,
+Errors topLevelError,
+TopicPartition topicPartition,
+Errors partitionLevelError,
+int leaderEpoch,
+int leaderId,
+Endpoints endpoints
+) {
+BeginQuorumEpochResponseData response = new 
BeginQuorumEpochResponseData()
+.setErrorCode(topLevelError.code())
+.setTopics(
+Collections.singletonList(
+new BeginQuorumEpochResponseData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new 
BeginQuorumEpochResponseData.PartitionData()
+
.setErrorCode(partitionLevelError.code())
+
.setLeaderId(leaderId)
+
.setLeaderEpoch(leaderEpoch)
+)
+)
+)
+);
+
+if (apiVersion >= 1) {
+Optional address = 
endpoints.address(listenerName);
+if (address.isPresent() && leaderId >= 0) {
+// Populate the node endpoints
+BeginQuorumEpochResponseData.NodeEndpointCollection 
nodeEndpoints =
+new 
BeginQuorumEpochResponseData.NodeEndpointCollection(1);
+nodeE

Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2024-12-17 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1889111428


##
raft/src/test/java/org/apache/kafka/raft/KafkaNetworkChannelTest.java:
##
@@ -288,7 +290,7 @@ private ApiMessage buildTestRequest(ApiKeys key) {
 return VoteRequest.singletonRequest(topicPartition, clusterId, 
leaderEpoch, leaderId, lastEpoch, 329);
 
 case FETCH:
-FetchRequestData request = 
RaftUtil.singletonFetchRequest(topicPartition, topicId, fetchPartition ->
+FetchRequestData request = 
FetchRpc.singletonFetchRequest(topicPartition, topicId, fetchPartition ->

Review Comment:
   I wouldn't be upset having both Fetch and FetchSnapshot in the same class. 
But I guess same argument could be made for Begin and End Quorum (and I see how 
naming might get more difficult)



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2024-12-17 Thread via GitHub


ahuang98 commented on code in PR #16831:
URL: https://github.com/apache/kafka/pull/16831#discussion_r1889109304


##
raft/src/main/java/org/apache/kafka/raft/utils/VoteRpc.java:
##
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.raft.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.feature.SupportedVersionRange;
+import org.apache.kafka.common.message.AddRaftVoterRequestData;
+import org.apache.kafka.common.message.AddRaftVoterResponseData;
+import org.apache.kafka.common.message.RemoveRaftVoterRequestData;
+import org.apache.kafka.common.message.RemoveRaftVoterResponseData;
+import org.apache.kafka.common.message.UpdateRaftVoterRequestData;
+import org.apache.kafka.common.message.UpdateRaftVoterResponseData;
+import org.apache.kafka.common.message.VoteRequestData;
+import org.apache.kafka.common.message.VoteResponseData;
+import org.apache.kafka.common.network.ListenerName;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.raft.Endpoints;
+import org.apache.kafka.raft.LeaderAndEpoch;
+import org.apache.kafka.raft.ReplicaKey;
+
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.Optional;
+
+public class VoteRpc {
+public static VoteRequestData singletonVoteRequest(
+TopicPartition topicPartition,
+String clusterId,
+int candidateEpoch,
+ReplicaKey candidateKey,
+ReplicaKey voterKey,
+int lastEpoch,
+long lastEpochEndOffset
+) {
+return new VoteRequestData()
+.setClusterId(clusterId)
+.setVoterId(voterKey.id())
+.setTopics(
+Collections.singletonList(
+new VoteRequestData.TopicData()
+.setTopicName(topicPartition.topic())
+.setPartitions(
+Collections.singletonList(
+new 
VoteRequestData.PartitionData()
+
.setPartitionIndex(topicPartition.partition())
+
.setCandidateEpoch(candidateEpoch)
+
.setCandidateId(candidateKey.id())
+
.setCandidateDirectoryId(
+
candidateKey
+   
 .directoryId()
+   
 .orElse(ReplicaKey.NO_DIRECTORY_ID)
+)
+
.setVoterDirectoryId(
+
voterKey
+   
 .directoryId()
+   
 .orElse(ReplicaKey.NO_DIRECTORY_ID)
+)
+
.setLastOffsetEpoch(lastEpoch)
+
.setLastOffset(lastEpochEndOffset)
+)
+)
+)
+);
+}
+
+public static VoteResponseData singletonVoteResponse(
+ListenerName listenerName,
+short apiVersion,
+Errors topLevelError,
+TopicPartition topicPartition,
+Errors partitionLevelError,
+int leaderEpoch,
+int leaderId,
+boolean voteGranted,
+Endpoints endpoints
+) {
+VoteResponseData response = new VoteResponseData()
+.setErrorCode(top

Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2024-12-01 Thread via GitHub


frankvicky commented on PR #16831:
URL: https://github.com/apache/kafka/pull/16831#issuecomment-2509640948

   Hi @chia7712 
   Could you please take a look?
   Many thanks 😺 


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-16907: Fix RaftUtil's type complexity [kafka]

2024-08-22 Thread via GitHub


frankvicky commented on PR #16831:
URL: https://github.com/apache/kafka/pull/16831#issuecomment-2303943487

   Will fix conflicts after 3.9 RC


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org