This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch revert-691-log
in repository https://gitbox.apache.org/repos/asf/ratis.git

commit e63b90ed3de0564b547b323c52d1d7c2eef424d9
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Sat Jul 23 12:29:23 2022 -0700

    Revert "RATIS-1633. Improve the grpc config output log information. (#691)"
    
    This reverts commit bc37ab504c2c429f3a858a4e847dee969455f1d5.
---
 .../main/java/org/apache/ratis/conf/ConfUtils.java    | 18 ------------------
 .../java/org/apache/ratis/grpc/GrpcConfigKeys.java    | 19 +++++++------------
 2 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/ratis-common/src/main/java/org/apache/ratis/conf/ConfUtils.java 
b/ratis-common/src/main/java/org/apache/ratis/conf/ConfUtils.java
index b21cc642..e5b04c67 100644
--- a/ratis-common/src/main/java/org/apache/ratis/conf/ConfUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/conf/ConfUtils.java
@@ -153,14 +153,6 @@ public interface ConfUtils {
     return get(integerGetter, key, defaultValue, logger, assertions);
   }
 
-  @SafeVarargs
-  static int getInt(
-      BiFunction<String, Integer, Integer> integerGetter,
-      String key, int defaultValue, int fallbackValue,
-      Consumer<String> logger, BiConsumer<String, Integer>... assertions) {
-    return get(integerGetter, key, defaultValue, fallbackValue, logger, 
assertions);
-  }
-
   @SafeVarargs
   static long getLong(
       BiFunction<String, Long, Long> longGetter,
@@ -223,16 +215,6 @@ public interface ConfUtils {
     return value;
   }
 
-  @SafeVarargs
-  static <T> T get(BiFunction<String, T, T> getter,
-      String key, T defaultValue, T fallbackValue,
-      Consumer<String> logger, BiConsumer<String, T>... assertions) {
-    T value = get(getter, key, defaultValue, null, assertions);
-    value = value != defaultValue ? value : fallbackValue;
-    logGet(key, value, defaultValue, logger);
-    return value;
-  }
-
   static InetSocketAddress getInetSocketAddress(
       BiFunction<String, String, String> stringGetter,
       String key, String defaultValue, Consumer<String> logger) {
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcConfigKeys.java 
b/ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcConfigKeys.java
index 0ba995de..c265ab2d 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcConfigKeys.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcConfigKeys.java
@@ -100,9 +100,9 @@ public interface GrpcConfigKeys {
     String PORT_KEY = PREFIX + ".port";
     int PORT_DEFAULT = -1;
     static int port(RaftProperties properties) {
-      final int fallbackServerPort = Server.port(properties, null);
-      return getInt(properties::getInt,
-          PORT_KEY, PORT_DEFAULT, fallbackServerPort, getDefaultLog(), 
requireMin(-1), requireMax(65536));
+      final int port = getInt(properties::getInt,
+          PORT_KEY, PORT_DEFAULT, getDefaultLog(), requireMin(-1), 
requireMax(65536));
+      return port != PORT_DEFAULT ? port : Server.port(properties);
     }
     static void setPort(RaftProperties properties, int port) {
       setInt(properties::setInt, PORT_KEY, port);
@@ -124,9 +124,9 @@ public interface GrpcConfigKeys {
     String PORT_KEY = PREFIX + ".port";
     int PORT_DEFAULT = -1;
     static int port(RaftProperties properties) {
-      final int fallbackServerPort = Server.port(properties, null);
-      return getInt(properties::getInt,
-          PORT_KEY, PORT_DEFAULT, fallbackServerPort, getDefaultLog(), 
requireMin(-1), requireMax(65536));
+      final int port = getInt(properties::getInt,
+          PORT_KEY, PORT_DEFAULT, getDefaultLog(), requireMin(-1), 
requireMax(65536));
+      return port != PORT_DEFAULT ? port : Server.port(properties);
     }
     static void setPort(RaftProperties properties, int port) {
       setInt(properties::setInt, PORT_KEY, port);
@@ -148,14 +148,9 @@ public interface GrpcConfigKeys {
     String PORT_KEY = PREFIX + ".port";
     int PORT_DEFAULT = 0;
     static int port(RaftProperties properties) {
-      return port(properties, getDefaultLog());
-    }
-
-    static int port(RaftProperties properties, Consumer<String> logger) {
       return getInt(properties::getInt,
-          PORT_KEY, PORT_DEFAULT, logger, requireMin(0), requireMax(65536));
+          PORT_KEY, PORT_DEFAULT, getDefaultLog(), requireMin(0), 
requireMax(65536));
     }
-
     static void setPort(RaftProperties properties, int port) {
       setInt(properties::setInt, PORT_KEY, port);
     }

Reply via email to