private TableConfig(@Nonnull String tableName, @Nonnull TableType tableType, @Nonnull SegmentsValidationAndRetentionConfig validationConfig, @Nonnull TenantConfig tenantConfig, @Nonnull IndexingConfig indexingConfig, @Nonnull TableCustomConfig customConfig, @Nullable QuotaConfig quotaConfig, @Nullable TableTaskConfig taskConfig, @Nullable RoutingConfig routingConfig) { _tableName = TableNameBuilder.forType(tableType).tableNameWithType(tableName); _tableType = tableType; _validationConfig = validationConfig; _tenantConfig = tenantConfig; _indexingConfig = indexingConfig; _customConfig = customConfig; _quotaConfig = quotaConfig; _taskConfig = taskConfig; _routingConfig = routingConfig; }
@DELETE @Produces(MediaType.APPLICATION_JSON) @Path("/segments/{tableName}") @ApiOperation(value = "Deletes all segments of a table", notes = "Deletes all segments of a table") public SuccessResponse deleteAllSegments( @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "realtime|offline", required = true) @QueryParam("type") String tableTypeStr) { CommonConstants.Helix.TableType tableType = Constants.validateTableType(tableTypeStr); if (tableType == null) { throw new ControllerApplicationException(LOGGER, "Table type must not be null", Response.Status.BAD_REQUEST); } PinotSegmentRestletResource .toggleStateInternal(tableName, StateType.DROP, tableType, null, _pinotHelixResourceManager); return new SuccessResponse( "All segments of table " + TableNameBuilder.forType(tableType).tableNameWithType(tableName) + " deleted"); }
public void updateMetadataConfigFor(String tableName, TableType type, TableCustomConfig newConfigs) throws Exception { String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType); if (tableConfig == null) { throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); } tableConfig.setCustomConfig(newConfigs); setExistingTableConfig(tableConfig, tableNameWithType, type); }
public void updateSegmentsValidationAndRetentionConfigFor(String tableName, TableType type, SegmentsValidationAndRetentionConfig newConfigs) throws Exception { String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType); if (tableConfig == null) { throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); } tableConfig.setValidationConfig(newConfigs); setExistingTableConfig(tableConfig, tableNameWithType, type); }
public void updateIndexingConfigFor(String tableName, TableType type, IndexingConfig newConfigs) throws Exception { String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, tableNameWithType); if (tableConfig == null) { throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); } tableConfig.setIndexingConfig(newConfigs); setExistingTableConfig(tableConfig, tableNameWithType, type); if (type == TableType.REALTIME) { ensureRealtimeClusterIsSetUp(tableConfig, tableName, newConfigs); } }
Map<String, String> simpleFields = znRecord.getSimpleFields(); TableType tableType = TableType.valueOf(simpleFields.get(TABLE_TYPE_KEY).toUpperCase()); String tableName = TableNameBuilder.forType(tableType).tableNameWithType(simpleFields.get(TABLE_NAME_KEY)); SegmentsValidationAndRetentionConfig validationConfig = JsonUtils.stringToObject(simpleFields.get(VALIDATION_CONFIG_KEY), SegmentsValidationAndRetentionConfig.class);
@Nonnull public static TableConfig fromJSONConfig(@Nonnull JsonNode jsonConfig) throws IOException { TableType tableType = TableType.valueOf(jsonConfig.get(TABLE_TYPE_KEY).asText().toUpperCase()); String tableName = TableNameBuilder.forType(tableType).tableNameWithType(jsonConfig.get(TABLE_NAME_KEY).asText()); SegmentsValidationAndRetentionConfig validationConfig = extractChildConfig(jsonConfig, VALIDATION_CONFIG_KEY, SegmentsValidationAndRetentionConfig.class); TenantConfig tenantConfig = extractChildConfig(jsonConfig, TENANT_CONFIG_KEY, TenantConfig.class); IndexingConfig indexingConfig = extractChildConfig(jsonConfig, INDEXING_CONFIG_KEY, IndexingConfig.class); TableCustomConfig customConfig = extractChildConfig(jsonConfig, CUSTOM_CONFIG_KEY, TableCustomConfig.class); QuotaConfig quotaConfig = null; if (jsonConfig.has(QUOTA_CONFIG_KEY)) { quotaConfig = extractChildConfig(jsonConfig, QUOTA_CONFIG_KEY, QuotaConfig.class); quotaConfig.validate(); } TableTaskConfig taskConfig = null; if (jsonConfig.has(TASK_CONFIG_KEY)) { taskConfig = extractChildConfig(jsonConfig, TASK_CONFIG_KEY, TableTaskConfig.class); } RoutingConfig routingConfig = null; if (jsonConfig.has(ROUTING_CONFIG_KEY)) { routingConfig = extractChildConfig(jsonConfig, ROUTING_CONFIG_KEY, RoutingConfig.class); } return new TableConfig(tableName, tableType, validationConfig, tenantConfig, indexingConfig, customConfig, quotaConfig, taskConfig, routingConfig); }
/** * Get QuotaConfig from property store. * @param rawTableName table name without table type. * @param tableType table type: offline or real-time. * @return QuotaConfig, which could be null. */ private QuotaConfig getQuotaConfigFromPropertyStore(String rawTableName, CommonConstants.Helix.TableType tableType) { ZkHelixPropertyStore<ZNRecord> propertyStore = _helixManager.getHelixPropertyStore(); String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(rawTableName); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(propertyStore, tableNameWithType); if (tableConfig == null) { return null; } return tableConfig.getQuotaConfig(); }
String serverTenant = TableNameBuilder.forType(tableType).tableNameWithType(tenantName); List<String> instancesInClusterWithTag = HelixHelper.getInstancesWithTag(helixManager, serverTenant); List<String> enabledInstancesWithTag = HelixHelper.getEnabledInstancesWithTag(helixManager, serverTenant);
CommonConstants.Helix.TableType tableType = tableConfig.getTableType(); String configTableName = tableConfig.getTableName(); String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName); if (!configTableName.equals(tableNameWithType)) { throw new ControllerApplicationException(LOGGER,
@Override public Map<String, ?> apply(Map<String, ?> childKeys, String pathPrefix) { // Adjust the name to add the table suffix to table.name.realtime/table.name.offline List<String> tableTypes = childKeys.get("table.types").map(tableTypesListOrString -> { if (tableTypesListOrString instanceof String) { return List.of((String) tableTypesListOrString); } else if (tableTypesListOrString instanceof Collection) { return List.ofAll((Collection<String>) tableTypesListOrString); } else { return List.empty(); } }).getOrElse(List.empty()).map(Object::toString); String tableName = childKeys.get("table.name").map(Object::toString).getOrElse( () -> childKeys.get("table.name.realtime").map(Object::toString) .getOrElse(() -> childKeys.get("table.name.offline").map(Object::toString).getOrNull())); Map<String, Object> remappedConfig = (Map<String, Object>) childKeys; for (String tableType : tableTypes) { String tableNameKey = "table.name." + tableType.toLowerCase(); CommonConstants.Helix.TableType type = CommonConstants.Helix.TableType.valueOf(tableType.toUpperCase()); remappedConfig = remappedConfig.put(tableNameKey, TableNameBuilder.forType(type).tableNameWithType(tableName)); } remappedConfig = remappedConfig.remove("table.name"); return remappedConfig; }