/** * Validates that settings being merged into {@code this} is targeting the same "subject", e.g. * user, table, namespace. * * @param mergee The quota settings to be merged into {@code this}. * @throws IllegalArgumentException if the subjects are not equal. */ void validateQuotaTarget(QuotaSettings mergee) { if (!Objects.equals(getUserName(), mergee.getUserName())) { throw new IllegalArgumentException("Mismatched user names on settings to merge"); } if (!Objects.equals(getTableName(), mergee.getTableName())) { throw new IllegalArgumentException("Mismatched table names on settings to merge"); } if (!Objects.equals(getNamespace(), mergee.getNamespace())) { throw new IllegalArgumentException("Mismatched namespace on settings to merge"); } if (!Objects.equals(getRegionServer(), mergee.getRegionServer())) { throw new IllegalArgumentException("Mismatched region server on settings to merge"); } } }
String ns = qs.getNamespace(); TableName tn = qs.getTableName(); if ((null == ns && null == tn) || (null != ns && null != tn)) {
for (QuotaSettings quotaSettings : scanner) { final String namespace = quotaSettings.getNamespace(); final TableName tableName = quotaSettings.getTableName(); if (QuotaType.SPACE != quotaSettings.getQuotaType()) {
/** * Convert a QuotaSettings to a protocol buffer SetQuotaRequest. * This is used internally by the Admin client to serialize the quota settings * and send them to the master. */ @InterfaceAudience.Private public static SetQuotaRequest buildSetQuotaRequestProto(final QuotaSettings settings) { SetQuotaRequest.Builder builder = SetQuotaRequest.newBuilder(); if (settings.getUserName() != null) { builder.setUserName(settings.getUserName()); } if (settings.getTableName() != null) { builder.setTableName(ProtobufUtil.toProtoTableName(settings.getTableName())); } if (settings.getNamespace() != null) { builder.setNamespace(settings.getNamespace()); } if (settings.getRegionServer() != null) { builder.setRegionServer(settings.getRegionServer()); } settings.setupSetQuotaRequest(builder); return builder.build(); }
try { for (QuotaSettings quotaSettings : scanner) { final String namespace = quotaSettings.getNamespace(); final TableName tableName = quotaSettings.getTableName(); final String userName = quotaSettings.getUserName();
@Test public void testFetchSpaceQuota() throws Exception { Multimap<TableName,QuotaSettings> tables = helper.createTablesWithSpaceQuotas(); // Can pass in an empty map, we're not consulting it. chore.initializeSnapshotStores(Collections.emptyMap()); // All tables that were created should have a quota defined. for (Entry<TableName,QuotaSettings> entry : tables.entries()) { final TableName table = entry.getKey(); final QuotaSettings qs = entry.getValue(); assertTrue("QuotaSettings was an instance of " + qs.getClass(), qs instanceof SpaceLimitSettings); SpaceQuota spaceQuota = null; if (qs.getTableName() != null) { spaceQuota = chore.getTableSnapshotStore().getSpaceQuota(table); assertNotNull("Could not find table space quota for " + table, spaceQuota); } else if (qs.getNamespace() != null) { spaceQuota = chore.getNamespaceSnapshotStore().getSpaceQuota(table.getNamespaceAsString()); assertNotNull("Could not find namespace space quota for " + table.getNamespaceAsString(), spaceQuota); } else { fail("Expected table or namespace space quota"); } final SpaceLimitSettings sls = (SpaceLimitSettings) qs; assertEquals(sls.getProto().getQuota(), spaceQuota); } TableName tableWithoutQuota = helper.createTable(); assertNull(chore.getTableSnapshotStore().getSpaceQuota(tableWithoutQuota)); }
/** * Validates that settings being merged into {@code this} is targeting the same "subject", e.g. * user, table, namespace. * * @param mergee The quota settings to be merged into {@code this}. * @throws IllegalArgumentException if the subjects are not equal. */ void validateQuotaTarget(QuotaSettings mergee) { if (!Objects.equals(getUserName(), mergee.getUserName())) { throw new IllegalArgumentException("Mismatched user names on settings to merge"); } if (!Objects.equals(getTableName(), mergee.getTableName())) { throw new IllegalArgumentException("Mismatched table names on settings to merge"); } if (!Objects.equals(getNamespace(), mergee.getNamespace())) { throw new IllegalArgumentException("Mismatched namespace on settings to merge"); } } }
/** * Convert a QuotaSettings to a protocol buffer SetQuotaRequest. * This is used internally by the Admin client to serialize the quota settings * and send them to the master. */ @InterfaceAudience.Private public static SetQuotaRequest buildSetQuotaRequestProto(final QuotaSettings settings) { SetQuotaRequest.Builder builder = SetQuotaRequest.newBuilder(); if (settings.getUserName() != null) { builder.setUserName(settings.getUserName()); } if (settings.getTableName() != null) { builder.setTableName(ProtobufUtil.toProtoTableName(settings.getTableName())); } if (settings.getNamespace() != null) { builder.setNamespace(settings.getNamespace()); } settings.setupSetQuotaRequest(builder); return builder.build(); }
/** * Validates that settings being merged into {@code this} is targeting the same "subject", e.g. * user, table, namespace. * * @param mergee The quota settings to be merged into {@code this}. * @throws IllegalArgumentException if the subjects are not equal. */ void validateQuotaTarget(QuotaSettings mergee) { if (!Objects.equals(getUserName(), mergee.getUserName())) { throw new IllegalArgumentException("Mismatched user names on settings to merge"); } if (!Objects.equals(getTableName(), mergee.getTableName())) { throw new IllegalArgumentException("Mismatched table names on settings to merge"); } if (!Objects.equals(getNamespace(), mergee.getNamespace())) { throw new IllegalArgumentException("Mismatched namespace on settings to merge"); } } }
/** * Convert a QuotaSettings to a protocol buffer SetQuotaRequest. This is used internally by the * Admin client to serialize the quota settings and send them to the master. */ public static SetQuotaRequest buildSetQuotaRequestProto(final QuotaSettings settings) { SetQuotaRequest.Builder builder = SetQuotaRequest.newBuilder(); if (settings.getUserName() != null) { builder.setUserName(settings.getUserName()); } if (settings.getTableName() != null) { builder.setTableName(ProtobufUtil.toProtoTableName(settings.getTableName())); } if (settings.getNamespace() != null) { builder.setNamespace(settings.getNamespace()); } settings.setupSetQuotaRequest(builder); return builder.build(); }
/** * Convert a QuotaSettings to a protocol buffer SetQuotaRequest. * This is used internally by the Admin client to serialize the quota settings * and send them to the master. */ @InterfaceAudience.Private public static SetQuotaRequest buildSetQuotaRequestProto(final QuotaSettings settings) { SetQuotaRequest.Builder builder = SetQuotaRequest.newBuilder(); if (settings.getUserName() != null) { builder.setUserName(settings.getUserName()); } if (settings.getTableName() != null) { builder.setTableName(ProtobufUtil.toProtoTableName(settings.getTableName())); } if (settings.getNamespace() != null) { builder.setNamespace(settings.getNamespace()); } settings.setupSetQuotaRequest(builder); return builder.build(); }
try { for (QuotaSettings quotaSettings : scanner) { final String namespace = quotaSettings.getNamespace(); final TableName tableName = quotaSettings.getTableName(); if (namespace != null) {
@Test public void testFetchSpaceQuota() throws Exception { Multimap<TableName,QuotaSettings> tables = helper.createTablesWithSpaceQuotas(); // Can pass in an empty map, we're not consulting it. chore.initializeSnapshotStores(Collections.emptyMap()); // All tables that were created should have a quota defined. for (Entry<TableName,QuotaSettings> entry : tables.entries()) { final TableName table = entry.getKey(); final QuotaSettings qs = entry.getValue(); assertTrue("QuotaSettings was an instance of " + qs.getClass(), qs instanceof SpaceLimitSettings); SpaceQuota spaceQuota = null; if (qs.getTableName() != null) { spaceQuota = chore.getTableSnapshotStore().getSpaceQuota(table); assertNotNull("Could not find table space quota for " + table, spaceQuota); } else if (qs.getNamespace() != null) { spaceQuota = chore.getNamespaceSnapshotStore().getSpaceQuota(table.getNamespaceAsString()); assertNotNull("Could not find namespace space quota for " + table.getNamespaceAsString(), spaceQuota); } else { fail("Expected table or namespace space quota"); } final SpaceLimitSettings sls = (SpaceLimitSettings) qs; assertEquals(sls.getProto().getQuota(), spaceQuota); } TableName tableWithoutQuota = helper.createTable(); assertNull(chore.getTableSnapshotStore().getSpaceQuota(tableWithoutQuota)); }