noob-se7en commented on code in PR #15008:
URL: https://github.com/apache/pinot/pull/15008#discussion_r1951428450


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java:
##########
@@ -641,6 +652,13 @@ protected TaskSchedulingInfo 
scheduleTask(PinotTaskGenerator taskGenerator, List
     for (TableConfig tableConfig : enabledTableConfigs) {
       String tableName = tableConfig.getTableName();
       try {
+        if 
(!_resourceUtilizationManager.isResourceUtilizationWithinLimits(tableName)) {

Review Comment:
   Some minion task like MergeRollup, RTO can decrease disk utilisation. Why 
would we disable them?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/validation/ResourceUtilizationInfo.java:
##########
@@ -0,0 +1,45 @@
+/**
+ * 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 java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.common.restlet.resources.DiskUsageInfo;
+
+
+/**
+ * This class is used to capture resource utilization information for all 
instances. The periodic task,
+ * <code>ResourceUtilizationChecker</code>, will update this information.
+ */
+public class ResourceUtilizationInfo {
+
+  private ResourceUtilizationInfo() {
+  }
+
+  // Assumption – instanceId is unique across all tenants
+  private static final Map<String, DiskUsageInfo> INSTANCE_DISK_USAGE_INFO = 
new HashMap<>();

Review Comment:
   we can remove stale instances



##########
pinot-controller/src/main/java/org/apache/pinot/controller/validation/RealtimeSegmentValidationManager.java:
##########
@@ -135,6 +138,18 @@ private boolean shouldEnsureConsuming(String 
tableNameWithType) {
     if (isTablePaused && 
pauseStatus.getReasonCode().equals(PauseState.ReasonCode.ADMINISTRATIVE)) {
       return false;
     }
+    try {
+      boolean isResourceUtilizationWithinLimits =
+          
_resourceUtilizationManager.isResourceUtilizationWithinLimits(tableNameWithType);
+      if (!isResourceUtilizationWithinLimits) {
+        LOGGER.warn("Resource utilization limit exceeded for table: {}", 
tableNameWithType);
+        _llcRealtimeSegmentManager.pauseConsumption(tableNameWithType,

Review Comment:
   I fear edge cases of 1)



##########
pinot-controller/src/main/java/org/apache/pinot/controller/validation/RealtimeSegmentValidationManager.java:
##########
@@ -135,6 +138,18 @@ private boolean shouldEnsureConsuming(String 
tableNameWithType) {
     if (isTablePaused && 
pauseStatus.getReasonCode().equals(PauseState.ReasonCode.ADMINISTRATIVE)) {
       return false;
     }
+    try {
+      boolean isResourceUtilizationWithinLimits =
+          
_resourceUtilizationManager.isResourceUtilizationWithinLimits(tableNameWithType);
+      if (!isResourceUtilizationWithinLimits) {
+        LOGGER.warn("Resource utilization limit exceeded for table: {}", 
tableNameWithType);
+        _llcRealtimeSegmentManager.pauseConsumption(tableNameWithType,
+            PauseState.ReasonCode.RESOURCE_UTILIZATION_LIMIT_EXCEEDED, 
"Resource utilization limit exceeded.");
+        return false;

Review Comment:
   Does this job and DiskChecker job run same time? There can be edge case 
where user fixed disk utilsation and RealtimeSegmentManager got stale disk 
utilisation info?



##########
pinot-controller/src/main/java/org/apache/pinot/controller/validation/ResourceUtilizationChecker.java:
##########
@@ -0,0 +1,85 @@
+/**
+ * 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.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 PoolingHttpClientConnectionManager _connectionManager;
+  private final ControllerMetrics _controllerMetrics;
+  private final DiskUtilizationChecker _diskUtilizationChecker;
+  private final Executor _executor;
+  private final PinotHelixResourceManager _helixResourceManager;
+
+  public ResourceUtilizationChecker(ControllerConf config, 
PoolingHttpClientConnectionManager connectionManager,
+      ControllerMetrics controllerMetrics, DiskUtilizationChecker 
diskUtilizationChecker, Executor executor,
+      PinotHelixResourceManager pinotHelixResourceManager) {
+    super(ResourceUtilizationChecker.class.getSimpleName(), 
config.getResourceUtilizationCheckerFrequency(),
+        config.getResourceUtilizationCheckerInitialDelay());
+    _connectionManager = connectionManager;
+    _controllerMetrics = controllerMetrics;
+    _diskUtilizationChecker = diskUtilizationChecker;
+    _executor = executor;
+    _helixResourceManager = pinotHelixResourceManager;
+  }
+
+  @Override
+  protected final void runTask(Properties periodicTaskProperties) {
+    _controllerMetrics.addMeteredTableValue(_taskName, 
ControllerMeter.CONTROLLER_PERIODIC_TASK_RUN, 1L);
+    Set<String> instances = new HashSet<>();
+    try {
+      Set<String> serverTenantNames = 
_helixResourceManager.getAllServerTenantNames();
+      for (String serverTenantName : serverTenantNames) {
+        Set<String> instancesForServerTenant = 
_helixResourceManager.getAllInstancesForServerTenant(serverTenantName);
+        if (!instancesForServerTenant.isEmpty()) {
+          instances.addAll(instancesForServerTenant);
+        }

Review Comment:
   Are these 2 ZK calls? This can be done in a single call as well to get live 
instances I think. like: 
      `List<String> liveInstances = 
helixDataAccessor.getChildNames(keyBuilder().liveInstances());`



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