suvodeep-pyne commented on code in PR #19737:
URL: https://github.com/apache/pinot/pull/19737#discussion_r4201363625


##########
pinot-server/src/main/java/org/apache/pinot/server/api/AdminApiApplication.java:
##########
@@ -84,6 +85,7 @@ protected void configure() {
         bind(_serverInstance.getServerMetrics()).to(ServerMetrics.class);
         bind(_accessControlFactory).to(AccessControlFactory.class);
         bind(reloadJobStatusCache).to(ServerReloadJobStatusCache.class);
+        bind(clusterConfigProvider).to(PinotClusterConfigProvider.class);

Review Comment:
   Agreed, switched in 7c753f3b71. `ReingestionConsumptionTimeout` is a 
`PinotClusterConfigChangeListener` registered in `BaseServerStarter` next to 
`ServerReloadJobStatusCache`. It holds a validated volatile timeout and is 
bound into HK2 as a typed object. The raw `PinotClusterConfigProvider` is no 
longer bound, so resources don't get the raw map.



##########
pinot-server/src/test/java/org/apache/pinot/server/api/resources/ReingestionResourceTest.java:
##########
@@ -0,0 +1,156 @@
+/**
+ * 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.server.api.resources;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.Response;
+import org.apache.helix.model.ClusterConfig;
+import org.apache.pinot.common.config.DefaultClusterConfigChangeHandler;
+import org.apache.pinot.server.api.BaseResourceTest;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static 
org.apache.pinot.server.api.resources.ReingestionResource.CHECK_INTERVAL_MS;
+import static 
org.apache.pinot.server.api.resources.ReingestionResource.getConsumptionTimeoutMs;
+import static 
org.apache.pinot.server.api.resources.ReingestionResource.waitForCondition;
+import static 
org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_REINGESTION_CONSUMPTION_TIMEOUT_MS;
+import static 
org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_REINGESTION_CONSUMPTION_TIMEOUT_MS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+
+/// Tests the consumption timeout resolution of [ReingestionResource] and the 
wiring of its injected dependencies.
+public class ReingestionResourceTest extends BaseResourceTest {

Review Comment:
   Split in 7c753f3b71. `ReingestionConsumptionTimeoutTest` and 
`ReingestionResourceTest` are plain TestNG classes. Only the endpoint tests in 
`ReingestionResourceApiTest` (the injection check and the new singleton check) 
extend `BaseResourceTest`.



##########
pinot-server/src/main/java/org/apache/pinot/server/api/resources/ReingestionResource.java:
##########
@@ -247,9 +266,38 @@ private void doReingestSegment(String realtimeTableName, 
SegmentZKMetadata segme
     }
   }
 
-  private void waitForCondition(
+  /// Resolves the consumption timeout for a re-ingestion job: the cluster 
config takes precedence over the server
+  /// config, which takes precedence over the default. A non-numeric or 
non-positive value is ignored with a warning.
+  @VisibleForTesting
+  static long getConsumptionTimeoutMs(PinotClusterConfigProvider 
clusterConfigProvider,
+      PinotConfiguration serverConf) {
+    Long timeoutMs = parseTimeoutMs(
+        
clusterConfigProvider.getClusterConfigs().get(CONFIG_OF_REINGESTION_CONSUMPTION_TIMEOUT_MS),
 "cluster");
+    if (timeoutMs == null) {
+      timeoutMs = 
parseTimeoutMs(serverConf.getProperty(CONFIG_OF_REINGESTION_CONSUMPTION_TIMEOUT_MS),
 "server");
+    }
+    return timeoutMs != null ? timeoutMs : 
DEFAULT_REINGESTION_CONSUMPTION_TIMEOUT_MS;
+  }
+
+  @Nullable
+  private static Long parseTimeoutMs(@Nullable String value, String 
configSource) {
+    if (value == null) {
+      return null;
+    }
+    Long timeoutMs = Longs.tryParse(value.trim());
+    if (timeoutMs == null || timeoutMs <= 0) {
+      LOGGER.warn("Ignoring invalid {} config: {}={}, expecting a positive 
number of milliseconds", configSource,
+          CONFIG_OF_REINGESTION_CONSUMPTION_TIMEOUT_MS, value);
+      return null;
+    }
+    return timeoutMs;
+  }
+
+  @VisibleForTesting
+  static void waitForCondition(
       Function<Void, Boolean> condition, long checkIntervalMs, long timeoutMs, 
long gracePeriodMs) {

Review Comment:
   Done in 7c753f3b71. The caller is now `writer::isDoneConsuming`.



##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java:
##########
@@ -1280,7 +1280,8 @@ private void initSegmentFetcher(PinotConfiguration config)
   }
 
   protected AdminApiApplication createServerAdminApp() {
-    return new AdminApiApplication(_serverInstance, _accessControlFactory, 
_reloadJobStatusCache, _serverConf);
+    return new AdminApiApplication(_serverInstance, _accessControlFactory, 
_reloadJobStatusCache,
+        _clusterConfigChangeHandler, _serverConf);

Review Comment:
   Agreed that it's a real failure mode, but it's pre-existing and shared by 
every listener-based server config: rate limits, query killing, throttlers and 
so on. If `addClusterfigChangeListener` fails, none of them get cluster 
updates, and `start()` logs the failure at ERROR. With the listener in 
7c753f3b71, this timeout behaves like the others and keeps its server-config 
value. A WARN for just this config wouldn't add much over that ERROR. A generic 
fix (e.g. failing startup, or a metric) would fit better in its own change, so 
I've left it out of this PR.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to