somandal commented on code in PR #15029: URL: https://github.com/apache/pinot/pull/15029#discussion_r1953298187
########## 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, Review Comment: Let me add comments about this Yes, you are right that this is not going to figure out that the deep store copy is not the same and can still result in reload. Do you know of a good way that exists today to figure out that the segments in deep store aren't up to date? I thought that this could be a future task to add a mechanism to figure this out and then add that pre-check API here. I'm still adding this because today we have a manual step to check if reload is needed before triggering rebalance. If the API returns that reload is needed, we're asked to trigger the reload before triggering the rebalance. This is to ensure that the current servers have the most up to date table configs. Let me know if you think otherwise. -- 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