Search in sources :

Example 1 with TableNameBuilder

use of com.linkedin.pinot.common.config.TableNameBuilder in project pinot by linkedin.

the class TableSizeReader method getTableSizeDetails.

/**
   * Get the table size.
   * This one polls all servers in parallel for segment sizes. In the response,
   * reported size indicates actual sizes collected from servers. For errors,
   * we use the size of largest segment as an estimate.
   * Returns null if the table is not found.
   * @param tableName
   * @param timeoutMsec
   * @return
   */
@Nullable
public TableSizeDetails getTableSizeDetails(@Nonnull String tableName, @Nonnegative int timeoutMsec) {
    Preconditions.checkNotNull(tableName, "Table name should not be null");
    Preconditions.checkArgument(timeoutMsec > 0, "Timeout value must be greater than 0");
    boolean hasRealtimeTable = false;
    boolean hasOfflineTable = false;
    CommonConstants.Helix.TableType tableType = TableNameBuilder.getTableTypeFromTableName(tableName);
    if (tableType != null) {
        hasRealtimeTable = tableType == CommonConstants.Helix.TableType.REALTIME;
        hasOfflineTable = tableType == CommonConstants.Helix.TableType.OFFLINE;
    } else {
        hasRealtimeTable = helixResourceManager.hasRealtimeTable(tableName);
        hasOfflineTable = helixResourceManager.hasOfflineTable(tableName);
    }
    if (!hasOfflineTable && !hasRealtimeTable) {
        return null;
    }
    TableSizeDetails tableSizeDetails = new TableSizeDetails(tableName);
    if (hasRealtimeTable) {
        String realtimeTableName = new TableNameBuilder(CommonConstants.Helix.TableType.REALTIME).forTable(tableName);
        tableSizeDetails.realtimeSegments = getTableSubtypeSize(realtimeTableName, timeoutMsec);
        tableSizeDetails.reportedSizeInBytes += tableSizeDetails.realtimeSegments.reportedSizeInBytes;
        tableSizeDetails.estimatedSizeInBytes += tableSizeDetails.realtimeSegments.estimatedSizeInBytes;
    }
    if (hasOfflineTable) {
        String offlineTableName = new TableNameBuilder(CommonConstants.Helix.TableType.OFFLINE).forTable(tableName);
        tableSizeDetails.offlineSegments = getTableSubtypeSize(offlineTableName, timeoutMsec);
        tableSizeDetails.reportedSizeInBytes += tableSizeDetails.offlineSegments.reportedSizeInBytes;
        tableSizeDetails.estimatedSizeInBytes += tableSizeDetails.offlineSegments.estimatedSizeInBytes;
    }
    return tableSizeDetails;
}
Also used : TableNameBuilder(com.linkedin.pinot.common.config.TableNameBuilder) Nullable(javax.annotation.Nullable)

Example 2 with TableNameBuilder

use of com.linkedin.pinot.common.config.TableNameBuilder in project pinot by linkedin.

the class PinotHelixResourceManager method getTableConfig.

public AbstractTableConfig getTableConfig(String tableName, TableType type) throws JsonParseException, JsonMappingException, JsonProcessingException, JSONException, IOException {
    String actualTableName = new TableNameBuilder(type).forTable(tableName);
    AbstractTableConfig config = null;
    if (type == TableType.REALTIME) {
        config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
    } else {
        config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
    }
    return config;
}
Also used : AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) TableNameBuilder(com.linkedin.pinot.common.config.TableNameBuilder)

Example 3 with TableNameBuilder

use of com.linkedin.pinot.common.config.TableNameBuilder in project pinot by linkedin.

the class PinotHelixResourceManager method updateSegmentsValidationAndRetentionConfigFor.

public void updateSegmentsValidationAndRetentionConfigFor(String tableName, TableType type, SegmentsValidationAndRetentionConfig newConfigs) throws Exception {
    String actualTableName = new TableNameBuilder(type).forTable(tableName);
    AbstractTableConfig config;
    if (type == TableType.REALTIME) {
        config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
    } else {
        config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
    }
    if (config == null) {
        throw new RuntimeException("tableName : " + tableName + " of type : " + type + " not found");
    }
    config.setValidationConfig(newConfigs);
    setTableConfig(config, actualTableName, type);
}
Also used : AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) TableNameBuilder(com.linkedin.pinot.common.config.TableNameBuilder)

Example 4 with TableNameBuilder

use of com.linkedin.pinot.common.config.TableNameBuilder in project pinot by linkedin.

the class PinotHelixResourceManager method updateMetadataConfigFor.

public void updateMetadataConfigFor(String tableName, TableType type, TableCustomConfig newConfigs) throws Exception {
    String actualTableName = new TableNameBuilder(type).forTable(tableName);
    AbstractTableConfig config;
    if (type == TableType.REALTIME) {
        config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
    } else {
        config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
    }
    if (config == null) {
        throw new RuntimeException("tableName : " + tableName + " of type : " + type + " not found");
    }
    config.setCustomConfigs(newConfigs);
    setTableConfig(config, actualTableName, type);
}
Also used : AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) TableNameBuilder(com.linkedin.pinot.common.config.TableNameBuilder)

Example 5 with TableNameBuilder

use of com.linkedin.pinot.common.config.TableNameBuilder in project pinot by linkedin.

the class PinotHelixResourceManager method getBrokerInstancesForTable.

public List<String> getBrokerInstancesForTable(String tableName, TableType type) throws JsonParseException, JsonMappingException, JsonProcessingException, JSONException, IOException {
    String actualTableName = new TableNameBuilder(type).forTable(tableName);
    AbstractTableConfig config = null;
    if (type == TableType.REALTIME) {
        config = ZKMetadataProvider.getRealtimeTableConfig(getPropertyStore(), actualTableName);
    } else {
        config = ZKMetadataProvider.getOfflineTableConfig(getPropertyStore(), actualTableName);
    }
    String brokerTenantName = ControllerTenantNameBuilder.getBrokerTenantNameForTenant(config.getTenantConfig().getBroker());
    List<String> serverInstances = _helixAdmin.getInstancesInClusterWithTag(_helixClusterName, brokerTenantName);
    return serverInstances;
}
Also used : AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) TableNameBuilder(com.linkedin.pinot.common.config.TableNameBuilder)

Aggregations

TableNameBuilder (com.linkedin.pinot.common.config.TableNameBuilder)7 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)6 OfflineTableConfig (com.linkedin.pinot.common.config.OfflineTableConfig)1 RealtimeTableConfig (com.linkedin.pinot.common.config.RealtimeTableConfig)1 Nullable (javax.annotation.Nullable)1