9aman commented on code in PR #15008:
URL: https://github.com/apache/pinot/pull/15008#discussion_r1955621704


##########
pinot-controller/src/main/java/org/apache/pinot/controller/validation/ResourceUtilizationChecker.java:
##########
@@ -0,0 +1,94 @@
+/**
+ * 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.validation;
+
+import com.google.common.collect.BiMap;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.pinot.common.metrics.ControllerMeter;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.LeadControllerManager;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.CompletionServiceHelper;
+import org.apache.pinot.core.periodictask.BasePeriodicTask;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is responsible for checking resource utilization for Pinot 
instances. To begin with, it checks
+ * disk utilization for all server instances. The computed disk utilization is 
stored in the class
+ * <code>org.apache.pinot.controller.validation.ResourceUtilizationInfo</code>.
+ */
+public class ResourceUtilizationChecker extends BasePeriodicTask {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ResourceUtilizationChecker.class);
+  private final static String TASK_NAME = 
ResourceUtilizationChecker.class.getSimpleName();
+
+  private final PoolingHttpClientConnectionManager _connectionManager;
+  private final ControllerMetrics _controllerMetrics;
+  private final DiskUtilizationChecker _diskUtilizationChecker;
+  private final Executor _executor;
+  private final PinotHelixResourceManager _helixResourceManager;
+  private final LeadControllerManager _leadControllerManager;
+
+  public ResourceUtilizationChecker(ControllerConf config, 
PoolingHttpClientConnectionManager connectionManager,
+      ControllerMetrics controllerMetrics, DiskUtilizationChecker 
diskUtilizationChecker, Executor executor,
+      PinotHelixResourceManager pinotHelixResourceManager, 
LeadControllerManager leadControllerManager) {
+    super(TASK_NAME, config.getResourceUtilizationCheckerFrequency(),
+        config.getResourceUtilizationCheckerInitialDelay());
+    _connectionManager = connectionManager;
+    _controllerMetrics = controllerMetrics;
+    _diskUtilizationChecker = diskUtilizationChecker;
+    _executor = executor;
+    _helixResourceManager = pinotHelixResourceManager;
+    _leadControllerManager = leadControllerManager;
+  }
+
+  @Override
+  protected final void runTask(Properties periodicTaskProperties) {
+    // Run the task only if this controller is the leader
+    if (!_leadControllerManager.isLeaderForTable(TASK_NAME)) {

Review Comment:
   Why are we passing TASK_NAME here ?
   iiuc this check is not at table level and pauses all the tables hosted by 
these servers. 
   What does this check here do ?



-- 
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