somandal commented on code in PR #15029:
URL: https://github.com/apache/pinot/pull/15029#discussion_r1953369779


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/DefaultRebalancePreChecker.java:
##########
@@ -0,0 +1,126 @@
+/**
+ * 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.helix.core.rebalance;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.pinot.common.assignment.InstanceAssignmentConfigUtils;
+import org.apache.pinot.common.exception.InvalidConfigException;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableMetadataReader;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.assignment.InstanceAssignmentConfig;
+import org.apache.pinot.spi.config.table.assignment.InstancePartitionsType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DefaultRebalancePreChecker implements RebalancePreChecker {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultRebalancePreChecker.class);
+
+  public static final String NEEDS_RELOAD_STATUS = "needsReloadStatus";
+  public static final String IS_MINIMIZE_DATA_MOVEMENT = 
"isMinimizeDataMovement";
+
+  @Override
+  public Map<String, String> doRebalancePreChecks(String rebalanceJobId, 
String tableNameWithType,
+      TableConfig tableConfig, PinotHelixResourceManager 
pinotHelixResourceManager) {
+    LOGGER.info("Start pre-checks for table: {} with rebalanceJobId: {}", 
tableNameWithType, rebalanceJobId);
+
+    Map<String, String> preCheckResult = new HashMap<>();
+    // Check for reload status
+    Boolean needsReload = checkReloadNeededOnServers(rebalanceJobId, 
tableNameWithType, pinotHelixResourceManager);
+    preCheckResult.put(NEEDS_RELOAD_STATUS,
+        needsReload == null ? "error" : needsReload ? String.valueOf(true) : 
String.valueOf(false));
+    // Check whether minimizeDataMovement is set in TableConfig
+    boolean isMinimizeDataMovement = 
checkIsMinimizeDataMovement(rebalanceJobId, tableNameWithType, tableConfig);
+    preCheckResult.put(IS_MINIMIZE_DATA_MOVEMENT, 
String.valueOf(isMinimizeDataMovement));
+
+    LOGGER.info("End pre-checks for table: {} with rebalanceJobId: {}", 
tableNameWithType, rebalanceJobId);
+    return preCheckResult;
+  }
+
+  private static Boolean checkReloadNeededOnServers(String rebalanceJobId, 
String tableNameWithType,
+      PinotHelixResourceManager pinotHelixResourceManager) {
+    // Use at most 10 threads to get whether reload is needed from servers
+    LOGGER.info("Fetching whether reload is needed for table: {} with 
rebalanceJobId: {}", tableNameWithType,
+        rebalanceJobId);
+    ExecutorService executorService = Executors.newFixedThreadPool(10);
+    Boolean needsReload = null;
+    if (pinotHelixResourceManager == null) {
+      return needsReload;

Review Comment:
   good catch, artifact of adding code afterwards 😅 
   I've modified the code to pass the `_executorService` from the 
`ControllerStarter` instead



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