You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/07/19 16:28:46 UTC

[GitHub] [incubator-pinot] mcvsubbu commented on a change in pull request #7173: [7156] Human Readable Controller Configs

mcvsubbu commented on a change in pull request #7173:
URL: https://github.com/apache/incubator-pinot/pull/7173#discussion_r672444492



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
##########
@@ -148,15 +205,23 @@ private static long getRandomInitialDelayInSeconds() {
     private static final int DEFAULT_STATUS_CONTROLLER_WAIT_FOR_PUSH_TIME_IN_SECONDS = 10 * 60; // 10 minutes
     private static final int DEFAULT_TASK_MANAGER_FREQUENCY_IN_SECONDS = -1; // Disabled
     private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_IN_SECONDS = 60 * 60; // 1 Hour.
-    private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_IN_SECONDS = 60 * 60; // 1 Hour.
+    private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_IN_SECONDS =
+        60 * 60; // 1 Hour.
 
     private static final int DEFAULT_SEGMENT_LEVEL_VALIDATION_INTERVAL_IN_SECONDS = 24 * 60 * 60;
     private static final int DEFAULT_SEGMENT_RELOCATOR_FREQUENCY_IN_SECONDS = 60 * 60;
   }
 
+  @Deprecated
   private static final String SERVER_ADMIN_REQUEST_TIMEOUT_SECONDS = "server.request.timeoutSeconds";
+  private static final String SERVER_ADMIN_REQUEST_TIMEOUT_PERIOD = "server.request.timeoutPeriod";
+
+  @Deprecated
   private static final String SEGMENT_COMMIT_TIMEOUT_SECONDS = "controller.realtime.segment.commit.timeoutSeconds";
+  private static final String SEGMENT_COMMIT_TIMEOUT_PERIOD = "controller.realtime.segment.commit.timeoutPeriod";

Review comment:
       This one should not be changed

##########
File path: pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java
##########
@@ -0,0 +1,158 @@
+/**
+ * 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.pinot.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import static org.apache.pinot.controller.ControllerConf.ControllerPeriodicTasksConf.*;
+
+
+public class ControllerConfTest {
+
+  private static final List<String> UNIT_CONFIGS =
+      List.of(RETENTION_MANAGER_FREQUENCY_IN_SECONDS, OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_IN_SECONDS,
+          OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_IN_SECONDS, REALTIME_SEGMENT_VALIDATION_FREQUENCY_IN_SECONDS,
+          REALTIME_SEGMENT_VALIDATION_INITIAL_DELAY_IN_SECONDS, BROKER_RESOURCE_VALIDATION_FREQUENCY_IN_SECONDS,
+          BROKER_RESOURCE_VALIDATION_INITIAL_DELAY_IN_SECONDS, STATUS_CHECKER_FREQUENCY_IN_SECONDS,
+          STATUS_CHECKER_WAIT_FOR_PUSH_TIME_IN_SECONDS, TASK_MANAGER_FREQUENCY_IN_SECONDS,
+          MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_IN_SECONDS, MINION_INSTANCES_CLEANUP_TASK_INITIAL_DELAY_SECONDS,
+          MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_SECONDS,
+          TASK_METRICS_EMITTER_FREQUENCY_IN_SECONDS, SEGMENT_RELOCATOR_FREQUENCY_IN_SECONDS,
+          SEGMENT_LEVEL_VALIDATION_INTERVAL_IN_SECONDS, STATUS_CHECKER_INITIAL_DELAY_IN_SECONDS,
+          OFFLINE_SEGMENT_INTERVAL_CHECKER_INITIAL_DELAY_IN_SECONDS,
+          DEPRECATED_REALTIME_SEGMENT_RELOCATION_INITIAL_DELAY_IN_SECONDS, SEGMENT_RELOCATOR_INITIAL_DELAY_IN_SECONDS);
+
+  private static final List<String> PERIOD_CONFIGS =
+      List.of(RETENTION_MANAGER_FREQUENCY_PERIOD, OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_PERIOD,
+          REALTIME_SEGMENT_VALIDATION_FREQUENCY_PERIOD, REALTIME_SEGMENT_VALIDATION_INITIAL_DELAY_PERIOD,
+          BROKER_RESOURCE_VALIDATION_FREQUENCY_PERIOD, BROKER_RESOURCE_VALIDATION_INITIAL_DELAY_PERIOD,
+          STATUS_CHECKER_FREQUENCY_PERIOD, STATUS_CHECKER_WAIT_FOR_PUSH_TIME_PERIOD, TASK_MANAGER_FREQUENCY_PERIOD,
+          MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_PERIOD, MINION_INSTANCES_CLEANUP_TASK_INITIAL_DELAY_PERIOD,
+          MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_PERIOD, TASK_METRICS_EMITTER_FREQUENCY_PERIOD,
+          SEGMENT_RELOCATOR_FREQUENCY_PERIOD, SEGMENT_LEVEL_VALIDATION_INTERVAL_PERIOD,
+          STATUS_CHECKER_INITIAL_DELAY_PERIOD, OFFLINE_SEGMENT_INTERVAL_CHECKER_INITIAL_DELAY_PERIOD,
+          SEGMENT_RELOCATOR_INITIAL_DELAY_PERIOD);
+
+  private static final int DURATION_IN_SECONDS = 20;
+  private static final String DURATION_IN_PERIOD_VALID = "2m";
+  private static final int PERIOD_DURATION_IN_SECONDS = 120;
+  private static final String DURATION_IN_PERIOD_INVALID = "2m2m";
+
+  /**
+   * When both type of configs are present, then the human-readable period config overrides the unit config
+   */
+  @Test
+  public void periodConfigOverridesUnitConfig() {
+    //setup
+    Map<String, Object> controllerConfig = new HashMap<>();
+    UNIT_CONFIGS.forEach(config -> controllerConfig.put(config, DURATION_IN_SECONDS));
+    PERIOD_CONFIGS.forEach(config -> controllerConfig.put(config, DURATION_IN_PERIOD_VALID));
+    ControllerConf conf = new ControllerConf(controllerConfig);
+    //execution and assertion
+    assertOnDurations(conf, PERIOD_DURATION_IN_SECONDS);
+  }
+
+  /**
+   * When only unit configs are supplied, then the correct converted value is returned.
+   */
+  @Test
+  public void suppliedUnitConfigsShouldReturnCorrectValues() {
+    //setup
+    Map<String, Object> controllerConfig = new HashMap<>();
+    UNIT_CONFIGS.forEach(config -> controllerConfig.put(config, DURATION_IN_SECONDS));
+    ControllerConf conf = new ControllerConf(controllerConfig);
+    //execution and assertion
+    assertOnDurations(conf, DURATION_IN_SECONDS);
+  }
+
+  /**
+   * When only period configs are supplied, then the correct converted value is returned.
+   */
+  @Test
+  public void suppliedPeriodConfigsShouldReturnCorrectValues() {
+    //setup
+    Map<String, Object> controllerConfig = new HashMap<>();
+    PERIOD_CONFIGS.forEach(config -> controllerConfig.put(config, DURATION_IN_PERIOD_VALID));
+    ControllerConf conf = new ControllerConf(controllerConfig);
+    //execution and assertion
+    assertOnDurations(conf, PERIOD_DURATION_IN_SECONDS);
+  }
+
+  /**
+   * When valid unit config and invalid period config are specified, then an {@link IllegalArgumentException} is thrown (valid unit
+   * config does not override invalid period config)
+   */
+  @Test(expectedExceptions = IllegalArgumentException.class)

Review comment:
       Expected exceptions are good, but I prefer fielding specific exceptions at the specific points where we expect them. That makes it easy to add more code to the test, or re-factor things, etc. and not worry about the test passing if we accidentally get IllegalArgumentException some place else.

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
##########
@@ -148,15 +205,23 @@ private static long getRandomInitialDelayInSeconds() {
     private static final int DEFAULT_STATUS_CONTROLLER_WAIT_FOR_PUSH_TIME_IN_SECONDS = 10 * 60; // 10 minutes
     private static final int DEFAULT_TASK_MANAGER_FREQUENCY_IN_SECONDS = -1; // Disabled
     private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_IN_SECONDS = 60 * 60; // 1 Hour.
-    private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_IN_SECONDS = 60 * 60; // 1 Hour.
+    private static final int DEFAULT_MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_IN_SECONDS =
+        60 * 60; // 1 Hour.
 
     private static final int DEFAULT_SEGMENT_LEVEL_VALIDATION_INTERVAL_IN_SECONDS = 24 * 60 * 60;
     private static final int DEFAULT_SEGMENT_RELOCATOR_FREQUENCY_IN_SECONDS = 60 * 60;
   }
 
+  @Deprecated
   private static final String SERVER_ADMIN_REQUEST_TIMEOUT_SECONDS = "server.request.timeoutSeconds";
+  private static final String SERVER_ADMIN_REQUEST_TIMEOUT_PERIOD = "server.request.timeoutPeriod";

Review comment:
       This one should not be changed. We don't expect people to configure this value in minutes or hours.




-- 
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: commits-unsubscribe@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org