Search in sources :

Example 1 with SpaceLimitRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest in project hbase by apache.

the class TestQuotaSettingsFactory method testSpaceLimitSettingsForDeletes.

@Test
public void testSpaceLimitSettingsForDeletes() {
    final String ns = "ns1";
    final TableName tn = TableName.valueOf("tn1");
    QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns);
    assertNotNull("QuotaSettings should not be null", nsSettings);
    assertTrue("Should be an instance of SpaceLimitSettings", nsSettings instanceof SpaceLimitSettings);
    SpaceLimitRequest nsProto = ((SpaceLimitSettings) nsSettings).getProto();
    assertTrue("Request should have a SpaceQuota", nsProto.hasQuota());
    assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove());
    QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn);
    assertNotNull("QuotaSettings should not be null", tableSettings);
    assertTrue("Should be an instance of SpaceLimitSettings", tableSettings instanceof SpaceLimitSettings);
    SpaceLimitRequest tableProto = ((SpaceLimitSettings) tableSettings).getProto();
    assertTrue("Request should have a SpaceQuota", tableProto.hasQuota());
    assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove());
}
Also used : TableName(org.apache.hadoop.hbase.TableName) SpaceLimitRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest) Test(org.junit.Test)

Example 2 with SpaceLimitRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest in project hbase by apache.

the class TestQuotaSettingsFactory method testSpaceLimitSettings.

@Test
public void testSpaceLimitSettings() {
    final TableName tableName = TableName.valueOf("foo");
    // 75GB
    final long sizeLimit = 1024L * 1024L * 1024L * 75;
    final SpaceViolationPolicy violationPolicy = SpaceViolationPolicy.NO_INSERTS;
    QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tableName, sizeLimit, violationPolicy);
    assertNotNull("QuotaSettings should not be null", settings);
    assertTrue("Should be an instance of SpaceLimitSettings", settings instanceof SpaceLimitSettings);
    SpaceLimitSettings spaceLimitSettings = (SpaceLimitSettings) settings;
    SpaceLimitRequest protoRequest = spaceLimitSettings.getProto();
    assertTrue("Request should have a SpaceQuota", protoRequest.hasQuota());
    SpaceQuota quota = protoRequest.getQuota();
    assertEquals(sizeLimit, quota.getSoftLimit());
    assertEquals(violationPolicy, ProtobufUtil.toViolationPolicy(quota.getViolationPolicy()));
    assertFalse("The remove attribute should be false", quota.getRemove());
}
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) Test(org.junit.Test)

Example 3 with SpaceLimitRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest 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 4 with SpaceLimitRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest 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)

Example 5 with SpaceLimitRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest in project hbase by apache.

the class TestQuotaAdmin method assertSpaceQuota.

private void assertSpaceQuota(long sizeLimit, SpaceViolationPolicy violationPolicy, QuotaSettings actualSettings) {
    assertTrue("The actual QuotaSettings was not an instance of " + SpaceLimitSettings.class + " but of " + actualSettings.getClass(), actualSettings instanceof SpaceLimitSettings);
    SpaceLimitRequest spaceLimitRequest = ((SpaceLimitSettings) actualSettings).getProto();
    assertEquals(sizeLimit, spaceLimitRequest.getQuota().getSoftLimit());
    assertEquals(violationPolicy, ProtobufUtil.toViolationPolicy(spaceLimitRequest.getQuota().getViolationPolicy()));
}
Also used : SpaceLimitRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceLimitRequest)

Aggregations

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