J-HowHuang commented on code in PR #16202: URL: https://github.com/apache/pinot/pull/16202#discussion_r2196097182
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/tenant/TenantTableWithProperties.java: ########## @@ -0,0 +1,165 @@ +/** + * 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.tenant; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; +import org.apache.pinot.common.exception.InvalidConfigException; +import org.apache.pinot.controller.util.TableSizeReader; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Class to hold table properties when listing tables for a tenant during rebalancing. + * This class contains pre-defined properties of a table that are relevant + * for making include/exclude decisions during tenant rebalance operations. + * The properties focus on factors that could impact rebalance performance and stability. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TenantTableWithProperties { + // Basic table identification + private static final Logger LOGGER = LoggerFactory.getLogger(TenantTableWithProperties.class); + + private String _tableNameWithType; + private TableType _tableType; + private boolean _isDimTable; + private int _replication; + private int _totalSegments; + private long _estimatedTableSizeInBytes; + private boolean _isUpsertEnabled; + private boolean _isDedupEnabled; + + private static final int TABLE_SIZE_READER_TIMEOUT_MS = 10000; // 10 seconds + + @JsonCreator + public TenantTableWithProperties( + @JsonProperty("tableNameWithType") String tableNameWithType, + @JsonProperty("tableType") TableType tableType, + @JsonProperty("isDimTable") boolean isDimTable, + @JsonProperty("replication") int replication, + @JsonProperty("totalSegments") int totalSegments, + @JsonProperty("estimatedTableSizeInBytes") long estimatedTableSizeInBytes, + @JsonProperty("isUpsertEnabled") boolean isUpsertEnabled, + @JsonProperty("isDedupEnabled") boolean isDedupEnabled) { + _tableNameWithType = tableNameWithType; + _tableType = tableType; + _isDimTable = isDimTable; + _replication = replication; + _totalSegments = totalSegments; + _estimatedTableSizeInBytes = estimatedTableSizeInBytes; + _isUpsertEnabled = isUpsertEnabled; + _isDedupEnabled = isDedupEnabled; + } + + public TenantTableWithProperties(TableConfig tableConfig, Map<String, Map<String, String>> idealStateInstanceStateMap, + TableSizeReader tableSizeReader) { + _tableNameWithType = tableConfig.getTableName(); + _tableType = tableConfig.getTableType(); + _isDimTable = tableConfig.isDimTable(); + _replication = Integer.MAX_VALUE; + for (Map<String, String> instanceState : idealStateInstanceStateMap.values()) { + _replication = Math.min(instanceState.size(), _replication); + } + if (_replication == Integer.MAX_VALUE) { + _replication = 0; // No instances available + } Review Comment: You're right, I think in this case the table config value is more relevant, as this is telling users if they need downtime rebalance or not for some tables, which is relevant to the table value of replication. -- 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