@Nullable public static TableConfig getTableConfig(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String tableNameWithType) { ZNRecord znRecord = propertyStore .get(constructPropertyStorePathForResourceConfig(tableNameWithType), null, AccessOption.PERSISTENT); if (znRecord == null) { return null; } try { return TableConfig.fromZnRecord(znRecord); } catch (Exception e) { LOGGER.error("Caught exception while getting table configuration for table: {}", tableNameWithType, e); return null; } }
private TableConfig getTableConfig(String tableName) throws Exception { return TableConfig.fromZnRecord( _propertyStore.get(ZKMetadataProvider.constructPropertyStorePathForResourceConfig(tableName), null, 0)); }
private void validateTableConfig() throws Exception { List<String> tableNames = getTableNames(); LOGGER.info("Validating table config for tables: " + tableNames); for (String tableName : tableNames) { LOGGER.info(" Validating table config for table: \"{}\"", tableName); try { ZNRecord record = _helixPropertyStore.get(TABLE_CONFIG_PATH + "/" + tableName, null, 0); TableConfig tableConfig = TableConfig.fromZnRecord(record); if (!TableConfigValidator.validate(tableConfig)) { LOGGER.error(" Table config validation failed for table: \"{}\"", tableName); } } catch (Exception e) { LOGGER.error(" Caught exception while validating table config for table: \"{}\"", tableName, e); } } }
public List<String> getAllTenantTables() throws Exception { String tableConfigPath = "/CONFIGS/TABLE"; List<ZNRecord> tableConfigs = _propertyStore.getChildren(tableConfigPath, null, 0); List<String> tables = new ArrayList<>(128); for (ZNRecord znRecord : tableConfigs) { TableConfig tableConfig = TableConfig.fromZnRecord(znRecord); if (tableConfig.getTenantConfig().getServer().equals(_tenantName)) { tables.add(tableConfig.getTableName()); } } return tables; }
private TableConfig getTableConfig(String tableName) throws IOException { ZNRecordSerializer serializer = new ZNRecordSerializer(); String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, zkPath); ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<>(zkHost, serializer, path); ZNRecord tcZnRecord = propertyStore.get("/CONFIGS/TABLE/" + tableName, null, 0); TableConfig tableConfig = TableConfig.fromZnRecord(tcZnRecord); LOGGER.debug("Loaded table config"); return tableConfig; }
/** * Rebalances a table * @param tableName * @throws Exception */ public void rebalanceTable(String tableName) throws Exception { String tableConfigPath = "/CONFIGS/TABLE/" + tableName; Stat stat = new Stat(); ZNRecord znRecord = propertyStore.get(tableConfigPath, stat, 0); TableConfig tableConfig = TableConfig.fromZnRecord(znRecord); String tenantName = tableConfig.getTenantConfig().getServer().replaceAll(TableType.OFFLINE.toString(), "") .replace(TableType.OFFLINE.toString(), ""); rebalanceTable(tableName, tenantName); }
/** * rebalances all tables for the tenant * @param tenantName */ public void rebalanceTenantTables(String tenantName) throws Exception { String tableConfigPath = "/CONFIGS/TABLE"; List<Stat> stats = new ArrayList<>(); List<ZNRecord> tableConfigs = propertyStore.getChildren(tableConfigPath, stats, 0); String rawTenantName = tenantName.replaceAll("_OFFLINE", "").replace("_REALTIME", ""); int nRebalances = 0; for (ZNRecord znRecord : tableConfigs) { TableConfig tableConfig; try { tableConfig = TableConfig.fromZnRecord(znRecord); } catch (Exception e) { LOGGER.warn("Failed to parse table configuration for ZnRecord id: {}. Skipping", znRecord.getId()); continue; } if (tableConfig.getTenantConfig().getServer().equals(rawTenantName)) { LOGGER.info(tableConfig.getTableName() + ":" + tableConfig.getTenantConfig().getServer()); nRebalances++; rebalanceTable(tableConfig.getTableName(), tenantName); } } if (nRebalances == 0) { LOGGER.info("No tables found for tenant " + tenantName); } }
String znRecordId = tableConfigZnRecord.getId(); if (TableNameBuilder.getTableTypeFromTableName(znRecordId) == TableType.REALTIME) { TableConfig tableConfig = TableConfig.fromZnRecord(tableConfigZnRecord); StreamConfig metadata = new StreamConfig(tableConfig.getIndexingConfig().getStreamConfigs()); if (metadata.hasHighLevelConsumerType()) {
tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals(tableConfigToCompare.getTableName(), tableConfig.getTableName()); Assert.assertNull(tableConfigToCompare.getQuotaConfig()); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals(tableConfigToCompare.getTableName(), tableConfig.getTableName()); Assert.assertNotNull(tableConfigToCompare.getQuotaConfig()); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals(tableConfigToCompare.getTableName(), tableConfig.getTableName()); Assert.assertNotNull(tableConfigToCompare.getTenantConfig()); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals(tableConfigToCompare.getTableName(), tableConfig.getTableName()); Assert.assertNotNull(tableConfigToCompare.getTenantConfig()); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); checkTableConfigWithAssignmentConfig(tableConfig, tableConfigToCompare); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals( tableConfigToCompare.getIndexingConfig().getStreamConsumptionConfig().getStreamPartitionAssignmentStrategy(), tableConfigToCompare = TableConfig.fromZnRecord(znRecord); checkTableConfigWithStarTreeConfig(tableConfig, tableConfigToCompare); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); checkTableConfigWithHllConfig(tableConfig, tableConfigToCompare);