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

apucher pushed a commit to branch pinot-internode-tls
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 468a65ae459cb679ec39eb86bd62ac0bb2e8cea5
Author: Alexander Pucher <[email protected]>
AuthorDate: Wed Jan 6 13:48:05 2021 -0800

    more assertions
---
 .../broker/broker/BrokerAdminApiApplication.java   |  2 +-
 .../apache/pinot/controller/ControllerConf.java    | 24 +++++++++++++---------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git 
a/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java
 
b/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java
index 4eb8f3f..821e4aa 100644
--- 
a/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java
+++ 
b/pinot-broker/src/main/java/org/apache/pinot/broker/broker/BrokerAdminApiApplication.java
@@ -71,7 +71,7 @@ public class BrokerAdminApiApplication extends ResourceConfig 
{
     int brokerQueryPort = 
brokerConf.getProperty(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT,
         CommonConstants.Helix.DEFAULT_BROKER_QUERY_PORT);
 
-    Preconditions.checkArgument(brokerQueryPort > 0);
+    Preconditions.checkArgument(brokerQueryPort > 0, "broker client port must 
be > 0");
     _baseUri = URI.create(String.format("%s://0.0.0.0:%d/", 
getBrokerClientProtocol(brokerConf), brokerQueryPort));
 
     _httpServer = buildHttpsServer(brokerConf);
diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
index e080220..5d308d9 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.controller;
 
+import com.google.common.base.Preconditions;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -37,6 +38,10 @@ import static 
org.apache.pinot.common.utils.CommonConstants.Controller.DEFAULT_M
 
 
 public class ControllerConf extends PinotConfiguration {
+  public static final List<String> SUPPORTED_PROTOCOLS = Arrays.asList(
+      CommonConstants.HTTP_PROTOCOL,
+      CommonConstants.HTTPS_PROTOCOL);
+
   public static final String CONTROLLER_VIP_HOST = "controller.vip.host";
   public static final String CONTROLLER_VIP_PORT = "controller.vip.port";
   public static final String CONTROLLER_VIP_PROTOCOL = 
"controller.vip.protocol";
@@ -354,19 +359,11 @@ public class ControllerConf extends PinotConfiguration {
   }  
 
   public String getControllerVipProtocol() {
-    return Optional.ofNullable(getProperty(CONTROLLER_VIP_PROTOCOL))
-
-        .filter(protocol -> CommonConstants.HTTPS_PROTOCOL.equals(protocol))
-
-        .orElse(CommonConstants.HTTP_PROTOCOL);
+    return getSupportedProtocol(CONTROLLER_VIP_PROTOCOL);
   }
 
   public String getControllerBrokerProtocol() {
-    return Optional.ofNullable(getProperty(CONTROLLER_BROKER_PROTOCOL))
-
-        .filter(protocol -> CommonConstants.HTTPS_PROTOCOL.equals(protocol))
-
-        .orElse(CommonConstants.HTTP_PROTOCOL);
+    return getSupportedProtocol(CONTROLLER_BROKER_PROTOCOL);
   }
 
   public int getRetentionControllerFrequencyInSeconds() {
@@ -657,4 +654,11 @@ public class ControllerConf extends PinotConfiguration {
     }
     return seconds;
   }
+
+  private String getSupportedProtocol(String property) {
+    String value = getProperty(property, CommonConstants.HTTP_PROTOCOL);
+    Preconditions.checkArgument(SUPPORTED_PROTOCOLS.contains(value),
+        "Unsupported %s protocol '%s'", property, value);
+    return value;
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to