Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replication factor to be obtained from tenant configuration in case of dimension table #7848

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,30 @@
package org.apache.pinot.controller.validation;

import com.google.common.base.Preconditions;
import java.util.Set;
import javax.inject.Inject;
import org.apache.pinot.common.exception.InvalidConfigException;
import org.apache.pinot.common.metrics.ControllerGauge;
import org.apache.pinot.common.metrics.ControllerMetrics;
import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
import org.apache.pinot.controller.util.TableSizeReader;
import org.apache.pinot.spi.config.table.QuotaConfig;
import org.apache.pinot.spi.config.table.TableConfig;
import org.apache.pinot.spi.config.table.TenantConfig;
import org.apache.pinot.spi.utils.DataSizeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* Class to check if a new segment is within the configured storage quota for the table
*
*/
public class StorageQuotaChecker {
private static final Logger LOGGER = LoggerFactory.getLogger(StorageQuotaChecker.class);

@Inject
PinotHelixResourceManager _pinotHelixResourceManager;

private final TableSizeReader _tableSizeReader;
private final TableConfig _tableConfig;
private final ControllerMetrics _controllerMetrics;
Expand Down Expand Up @@ -80,7 +86,18 @@ public QuotaCheckerResponse isSegmentStorageWithinQuota(String segmentName, long
// 3. update predicted segment sizes
// 4. is the updated size within quota
QuotaConfig quotaConfig = _tableConfig.getQuotaConfig();
int numReplicas = _tableConfig.getValidationConfig().getReplicationNumber();
int numReplicas;

if (_tableConfig.isDimTable()) {
// If the table is a dimension table then fetch the tenant config and get the number of server belonging
// to the tenant
TenantConfig tenantConfig = _tableConfig.getTenantConfig();
Set<String> serverInstances = _pinotHelixResourceManager.getAllInstancesForServerTenant(tenantConfig.getServer());
numReplicas = serverInstances.size();
} else {
numReplicas = _tableConfig.getValidationConfig().getReplicationNumber();
}

final String tableNameWithType = _tableConfig.getTableName();

if (quotaConfig == null || quotaConfig.getStorage() == null) {
Expand Down