@Test public void testNoQuota() throws InvalidConfigException { StorageQuotaChecker checker = new MockStorageQuotaChecker(_tableConfig, _tableSizeReader, _controllerMetrics, _pinotHelixResourceManager); when(_tableConfig.getQuotaConfig()).thenReturn(null); StorageQuotaChecker.QuotaCheckerResponse res = checker.isSegmentStorageWithinQuota(TEST_DIR, "myTable", "segment", 1000); Assert.assertTrue(res.isSegmentWithinQuota); }
@Test public void testNoStorageQuotaConfig() throws InvalidConfigException { StorageQuotaChecker checker = new MockStorageQuotaChecker(_tableConfig, _tableSizeReader, _controllerMetrics, _pinotHelixResourceManager); when(_tableConfig.getQuotaConfig()).thenReturn(_quotaConfig); when(_quotaConfig.storageSizeBytes()).thenReturn(-1L); StorageQuotaChecker.QuotaCheckerResponse res = checker.isSegmentStorageWithinQuota(TEST_DIR, "myTable", "segment", 1000); Assert.assertTrue(res.isSegmentWithinQuota); }
CommonConstants.Helix.TableType tableType = tableConfig.getTableType(); if (tableType == CommonConstants.Helix.TableType.OFFLINE) { offlineQuotaConfig = tableConfig.getQuotaConfig(); realtimeQuotaConfig = getQuotaConfigFromPropertyStore(rawTableName, CommonConstants.Helix.TableType.REALTIME); } else { realtimeQuotaConfig = tableConfig.getQuotaConfig(); offlineQuotaConfig = getQuotaConfigFromPropertyStore(rawTableName, CommonConstants.Helix.TableType.OFFLINE); createRateLimiter(tableNameWithType, brokerResource, tableConfig.getQuotaConfig());
/** * 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(); }
private void validateLoadedConfig(TableConfig config) { Assert.assertEquals(config.getTableName(), "mytable_OFFLINE"); Assert.assertEquals(config.getQuotaConfig().getStorage(), "125 GiB"); Assert.assertEquals(config.getValidationConfig().getRetentionTimeValue(), "5"); Assert.assertEquals(config.getValidationConfig().getRetentionTimeUnit(), "DAYS"); Assert.assertEquals(config.getTenantConfig().getBroker(), "foo"); Assert.assertEquals(config.getTenantConfig().getServer(), "bar"); Assert.assertEquals(config.getIndexingConfig().getSortedColumn(), Lists.newArrayList("foo")); } }
setupTableSegmentSize(4800L, 900L, 0); when(_tableConfig.getTableName()).thenReturn(tableName); when(_tableConfig.getQuotaConfig()).thenReturn(_quotaConfig); when(_quotaConfig.storageSizeBytes()).thenReturn(3000L); when(_quotaConfig.getStorage()).thenReturn("3K");
QuotaConfig quotaConfig = _tableConfig.getQuotaConfig(); int numReplicas = _tableConfig.getValidationConfig().getReplicationNumber(); final String tableName = _tableConfig.getTableName();
Assert.assertEquals(tableConfig.getValidationConfig().getRetentionTimeValue(), "5"); Assert.assertEquals(tableConfig.getValidationConfig().getRetentionTimeUnit(), "DAYS"); Assert.assertNull(tableConfig.getQuotaConfig()); sendPutRequest(_controllerRequestURLBuilder.forUpdateTableConfig(tableName), tableConfig.toJSONConfigString()); modifiedConfig = getTableConfig(tableName, "REALTIME"); Assert.assertNotNull(modifiedConfig.getQuotaConfig()); Assert.assertEquals(modifiedConfig.getQuotaConfig().getStorage(), "10G"); Assert.assertNull(modifiedConfig.getQuotaConfig().getMaxQueriesPerSecond()); sendPutRequest(_controllerRequestURLBuilder.forUpdateTableConfig(tableName), tableConfig.toJSONConfigString()); modifiedConfig = getTableConfig(tableName, "REALTIME"); Assert.assertNotNull(modifiedConfig.getQuotaConfig().getMaxQueriesPerSecond()); Assert.assertEquals(modifiedConfig.getQuotaConfig().getMaxQueriesPerSecond(), "100.00");
Assert.assertEquals(tableConfig.getTableType(), TableType.OFFLINE); Assert.assertEquals(tableConfig.getIndexingConfig().getLoadMode(), "HEAP"); Assert.assertNull(tableConfig.getQuotaConfig()); Assert.assertNull(tableConfigToCompare.getQuotaConfig()); Assert.assertNull(tableConfigToCompare.getValidationConfig().getReplicaGroupStrategyConfig()); Assert.assertNull(tableConfigToCompare.getValidationConfig().getHllConfig()); tableConfigToCompare = TableConfig.fromZnRecord(znRecord); Assert.assertEquals(tableConfigToCompare.getTableName(), tableConfig.getTableName()); Assert.assertNull(tableConfigToCompare.getQuotaConfig()); Assert.assertNull(tableConfig.getValidationConfig().getReplicaGroupStrategyConfig()); Assert.assertNull(tableConfigToCompare.getValidationConfig().getHllConfig()); Assert.assertEquals(tableConfig.getTableType(), TableType.OFFLINE); Assert.assertEquals(tableConfig.getIndexingConfig().getLoadMode(), "HEAP"); Assert.assertNotNull(tableConfig.getQuotaConfig()); Assert.assertEquals(tableConfig.getQuotaConfig().getStorage(), "30G"); Assert.assertNull(tableConfig.getQuotaConfig().getMaxQueriesPerSecond()); Assert.assertNotNull(tableConfig.getQuotaConfig()); Assert.assertNotNull(tableConfig.getQuotaConfig().getMaxQueriesPerSecond()); Assert.assertEquals(tableConfig.getQuotaConfig().getMaxQueriesPerSecond(), "100.00"); Assert.assertNotNull(tableConfigToCompare.getQuotaConfig()); Assert .assertEquals(tableConfigToCompare.getQuotaConfig().getStorage(), tableConfig.getQuotaConfig().getStorage()); Assert.assertNotNull(tableConfigToCompare.getQuotaConfig());