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



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
##########
@@ -568,17 +666,21 @@ public void setDeletedSegmentsRetentionInDays(int 
retentionInDays) {
   }
 
   public int getTaskManagerFrequencyInSeconds() {
-    return 
getProperty(ControllerPeriodicTasksConf.TASK_MANAGER_FREQUENCY_IN_SECONDS,
-        ControllerPeriodicTasksConf.DEFAULT_TASK_MANAGER_FREQUENCY_IN_SECONDS);
+    return 
Optional.ofNullable(getProperty(ControllerPeriodicTasksConf.TASK_MANAGER_FREQUENCY_PERIOD))

Review comment:
       I am sure I am missing something. I don't see the UT for this case?

##########
File path: 
pinot-controller/src/test/java/org/apache/pinot/controller/ControllerConfTest.java
##########
@@ -0,0 +1,193 @@
+/**
+ * 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.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.pinot.spi.utils.TimeUtils;
+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> DEPRECATED_CONFIGS = Arrays
+      .asList(DEPRECATED_RETENTION_MANAGER_FREQUENCY_IN_SECONDS,
+          DEPRECATED_OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_IN_SECONDS,
+          DEPRECATED_OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_IN_SECONDS,
+          DEPRECATED_REALTIME_SEGMENT_VALIDATION_FREQUENCY_IN_SECONDS,
+          DEPRECATED_BROKER_RESOURCE_VALIDATION_FREQUENCY_IN_SECONDS, 
DEPRECATED_STATUS_CHECKER_FREQUENCY_IN_SECONDS,
+          DEPRECATED_TASK_MANAGER_FREQUENCY_IN_SECONDS, 
DEPRECATED_MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_IN_SECONDS,
+          
DEPRECATED_MINION_INSTANCES_CLEANUP_TASK_MIN_OFFLINE_TIME_BEFORE_DELETION_SECONDS,
+          DEPRECATED_TASK_METRICS_EMITTER_FREQUENCY_IN_SECONDS, 
DEPRECATED_SEGMENT_RELOCATOR_FREQUENCY_IN_SECONDS,
+          DEPRECATED_SEGMENT_LEVEL_VALIDATION_INTERVAL_IN_SECONDS,
+          DEPRECATED_REALTIME_SEGMENT_RELOCATION_INITIAL_DELAY_IN_SECONDS,
+          DEPRECATED_STATUS_CHECKER_WAIT_FOR_PUSH_TIME_IN_SECONDS);
+
+  private static final List<String> NEW_CONFIGS = Arrays
+      .asList(RETENTION_MANAGER_FREQUENCY_PERIOD, 
OFFLINE_SEGMENT_INTERVAL_CHECKER_FREQUENCY_PERIOD,
+          REALTIME_SEGMENT_VALIDATION_FREQUENCY_PERIOD, 
BROKER_RESOURCE_VALIDATION_FREQUENCY_PERIOD,
+          STATUS_CHECKER_FREQUENCY_PERIOD, TASK_MANAGER_FREQUENCY_PERIOD,
+          MINION_INSTANCES_CLEANUP_TASK_FREQUENCY_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_WAIT_FOR_PUSH_TIME_PERIOD);
+
+  private static final Random RAND = new Random();
+
+  /**
+   * When config contains: 1. Both deprecated config and the corresponding new 
config. 2. All new
+   * configurations are valid. 3. Some deprecated configurations are invalid. 
then new configs
+   * override deprecated configs (invalid deprecated configs do not throw 
exceptions when
+   * corresponding valid new configs are supplied as well)
+   */
+  @Test
+  public void 
validNewConfigOverridesCorrespondingValidOrInvalidOldConfigOnRead() {
+    //setup
+    Map<String, Object> controllerConfig = new HashMap<>();
+    int durationInSeconds = getRandomDurationInSeconds();
+    DEPRECATED_CONFIGS.forEach(config -> controllerConfig.put(config, 
durationInSeconds));
+    //put some invalid deprecated configs
+    controllerConfig.put(DEPRECATED_RETENTION_MANAGER_FREQUENCY_IN_SECONDS, 
getRandomString());
+    
controllerConfig.put(DEPRECATED_SEGMENT_LEVEL_VALIDATION_INTERVAL_IN_SECONDS, 
getRandomString());
+    //override all deprecated configs with valid new configs
+    String period = getRandomPeriodInMinutes();
+    NEW_CONFIGS.forEach(config -> controllerConfig.put(config, period));
+    ControllerConf conf = new ControllerConf(controllerConfig);
+    //execution and assertion
+    assertOnDurations(conf, 
TimeUnit.SECONDS.convert(TimeUtils.convertPeriodToMillis(period), 
TimeUnit.MILLISECONDS));
+  }
+
+  /**
+   * When config contains: 1. Both deprecated config and the corresponding new 
config. 2. All
+   * deprecated configurations are valid. 3. Some new configurations are 
invalid. then exceptions
+   * are thrown when invalid new configurations are read (there is no 
fall-back to the corresponding
+   * valid deprecated configuration). For all valid new configurations, they 
override the
+   * corresponding deprecated configuration.
+   */
+  @Test
+  public void 
invalidNewConfigShouldThrowExceptionOnReadWithoutFallbackToCorrespondingValidDeprecatedConfig()
 {
+    //setup
+    Map<String, Object> controllerConfig = new HashMap<>();
+    int durationInSeconds = getRandomDurationInSeconds();
+    //all deprecated configs should be valid
+    DEPRECATED_CONFIGS.forEach(config -> controllerConfig.put(config, 
durationInSeconds));
+    String randomPeriodInMinutes = getRandomPeriodInMinutes();

Review comment:
       In this case maybe it is ok, but in general, it is a good idea to set 
the seed for the random number up front, and print out the value of the seed 
(in system.out). This will make sure that if there is failure due to some 
random value, we can reproduce the test case by manually setting the seed to 
that value. Otherwise, we will face intermittent failures in tests without 
knowing why that happened.

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/ControllerConf.java
##########
@@ -74,60 +76,115 @@
   }
 
   public static class ControllerPeriodicTasksConf {
+
     // frequency configs
+    @Deprecated
     public static final String RETENTION_MANAGER_FREQUENCY_IN_SECONDS = 
"controller.retention.frequencyInSeconds";
+    public static final String RETENTION_MANAGER_FREQUENCY_PERIOD = 
"controller.retention.frequencyPeriod";
     @Deprecated
     // The ValidationManager has been split up into 3 separate tasks, each 
having their own frequency config settings
     public static final String 
DEPRECATED_VALIDATION_MANAGER_FREQUENCY_IN_SECONDS =
         "controller.validation.frequencyInSeconds";
+    @Deprecated

Review comment:
       Can you either remove 
`DEPRECATED_VALIDATION_MANAGER_FREQUENCY_IN_SECONDS` or add a comment before 
line 80 saying it has been deprecated since 0.5.0




-- 
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-unsubscr...@pinot.apache.org

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



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

Reply via email to