Search in sources :

Example 1 with SetQuotaRequest

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());
}
Also used : SpaceQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota) SpaceLimitRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest) SetQuotaRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest) Test(org.junit.Test)

Example 2 with SetQuotaRequest

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());
}
Also used : TableName(org.apache.hadoop.hbase.TableName) SpaceQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota) SpaceLimitRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest) SetQuotaRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest) Test(org.junit.Test)

Aggregations

SetQuotaRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest)2 SpaceLimitRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest)2 SpaceQuota (org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota)2 Test (org.junit.Test)2 TableName (org.apache.hadoop.hbase.TableName)1