hachikuji commented on a change in pull request #9881:
URL: https://github.com/apache/kafka/pull/9881#discussion_r557559024



##########
File path: raft/src/main/java/org/apache/kafka/raft/RaftConfig.java
##########
@@ -129,16 +133,41 @@ public String toString() {
                 QUORUM_LINGER_MS_DOC);
     }
 
+    private final int requestTimeoutMs;
+    private final int retryBackoffMs;
+    private final int electionTimeoutMs;
+    private final int electionBackoffMaxMs;
+    private final int fetchTimeoutMs;
+    private final int appendLingerMs;
+
     public RaftConfig(Properties props) {

Review comment:
       nit: I think this constructor is redundant. can we remove it?

##########
File path: raft/src/main/java/org/apache/kafka/raft/RaftConfig.java
##########
@@ -129,16 +133,41 @@ public String toString() {
                 QUORUM_LINGER_MS_DOC);
     }
 
+    private final int requestTimeoutMs;
+    private final int retryBackoffMs;
+    private final int electionTimeoutMs;
+    private final int electionBackoffMaxMs;
+    private final int fetchTimeoutMs;
+    private final int appendLingerMs;
+
     public RaftConfig(Properties props) {
         super(CONFIG, props);
+        requestTimeoutMs = getInt(QUORUM_REQUEST_TIMEOUT_MS_CONFIG);
+        retryBackoffMs = getInt(QUORUM_RETRY_BACKOFF_MS_CONFIG);
+        electionTimeoutMs = getInt(QUORUM_ELECTION_TIMEOUT_MS_CONFIG);
+        electionBackoffMaxMs = getInt(QUORUM_ELECTION_BACKOFF_MAX_MS_CONFIG);
+        fetchTimeoutMs = getInt(QUORUM_FETCH_TIMEOUT_MS_CONFIG);
+        appendLingerMs = getInt(QUORUM_LINGER_MS_CONFIG);
     }
 
-    public RaftConfig(Map<String, Object> props) {
+    public RaftConfig(Map<?, ?> props) {
         super(CONFIG, props);
+        requestTimeoutMs = getInt(QUORUM_REQUEST_TIMEOUT_MS_CONFIG);

Review comment:
       nit: the typical thing to do is invoke the other constructor. e.g. 
`this(props, true)`

##########
File path: raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
##########
@@ -2163,7 +2177,13 @@ public Long scheduleAppend(int epoch, List<T> records) {
 
     @Override
     public void close() {
-        kafkaRaftMetrics.close();
+        if (kafkaRaftMetrics != null) {
+            kafkaRaftMetrics.close();
+        }
+    }
+
+    public QuorumState quorum() {

Review comment:
       Any chance we can make this default access?

##########
File path: raft/src/test/java/org/apache/kafka/raft/RaftTestUtil.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.apache.kafka.common.Node;
+
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public class RaftTestUtil {
+    public static RaftConfig buildRaftConfig(int requestTimeoutMs,

Review comment:
       nit: convention in the raft code is to align first parameter on next 
line:
   ```
   public static RaftConfig buildRaftConfig(
       int requestTimeoutMs,
       int retryBackoffMs,
       ...
       List<Node> voterNodes
   ) {
   ```

##########
File path: raft/src/test/java/org/apache/kafka/raft/RaftConfigTest.java
##########
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 import java.util.Properties;
 
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

Review comment:
       This does not seem used?




----------------------------------------------------------------
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.

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


Reply via email to