use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest in project hbase by apache.
the class TestSpaceLimitSettings method testNamespaceQuota.
@Test
public void testNamespaceQuota() {
final String namespace = "foo_ns";
final long sizeLimit = 1024 * 1024;
final SpaceViolationPolicy policy = SpaceViolationPolicy.NO_WRITES;
SpaceLimitSettings settings = new SpaceLimitSettings(namespace, sizeLimit, policy);
SetQuotaRequest proto = QuotaSettings.buildSetQuotaRequestProto(settings);
assertFalse("User should be missing", proto.hasUserName());
assertFalse("TableName should be missing", proto.hasTableName());
assertEquals(namespace, proto.getNamespace());
SpaceLimitRequest spaceLimitReq = proto.getSpaceLimit();
assertNotNull("SpaceLimitRequest was null", spaceLimitReq);
SpaceQuota spaceQuota = spaceLimitReq.getQuota();
assertNotNull("SpaceQuota was null", spaceQuota);
assertEquals(sizeLimit, spaceQuota.getSoftLimit());
assertEquals(ProtobufUtil.toProtoViolationPolicy(policy), spaceQuota.getViolationPolicy());
assertEquals(QuotaType.SPACE, settings.getQuotaType());
SpaceLimitSettings copy = new SpaceLimitSettings(namespace, sizeLimit, policy);
assertEquals(settings, copy);
assertEquals(settings.hashCode(), copy.hashCode());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest in project hbase by apache.
the class TestSpaceLimitSettings method testTableQuota.
@Test
public void testTableQuota() {
final TableName tableName = TableName.valueOf("foo");
final long sizeLimit = 1024 * 1024;
final SpaceViolationPolicy policy = SpaceViolationPolicy.NO_WRITES;
SpaceLimitSettings settings = new SpaceLimitSettings(tableName, sizeLimit, policy);
SetQuotaRequest proto = QuotaSettings.buildSetQuotaRequestProto(settings);
assertFalse("User should be missing", proto.hasUserName());
assertFalse("Namespace should be missing", proto.hasNamespace());
assertEquals(ProtobufUtil.toProtoTableName(tableName), proto.getTableName());
SpaceLimitRequest spaceLimitReq = proto.getSpaceLimit();
assertNotNull("SpaceLimitRequest was null", spaceLimitReq);
SpaceQuota spaceQuota = spaceLimitReq.getQuota();
assertNotNull("SpaceQuota was null", spaceQuota);
assertEquals(sizeLimit, spaceQuota.getSoftLimit());
assertEquals(ProtobufUtil.toProtoViolationPolicy(policy), spaceQuota.getViolationPolicy());
assertEquals(QuotaType.SPACE, settings.getQuotaType());
SpaceLimitSettings copy = new SpaceLimitSettings(tableName, sizeLimit, policy);
assertEquals(settings, copy);
assertEquals(settings.hashCode(), copy.hashCode());
}
Aggregations