Search in sources :

Example 1 with SpaceQuotaSnapshot

use of org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot in project hbase by apache.

the class MetricsMasterWrapperImpl method getNamespaceSpaceUtilization.

@Override
public Map<String, Entry<Long, Long>> getNamespaceSpaceUtilization() {
    QuotaObserverChore quotaChore = master.getQuotaObserverChore();
    if (quotaChore == null) {
        return Collections.emptyMap();
    }
    Map<String, SpaceQuotaSnapshot> namespaceSnapshots = quotaChore.getNamespaceQuotaSnapshots();
    Map<String, Entry<Long, Long>> convertedData = new HashMap<>();
    for (Entry<String, SpaceQuotaSnapshot> entry : namespaceSnapshots.entrySet()) {
        convertedData.put(entry.getKey(), convertSnapshot(entry.getValue()));
    }
    return convertedData;
}
Also used : SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Entry(java.util.Map.Entry) HashMap(java.util.HashMap) QuotaObserverChore(org.apache.hadoop.hbase.quotas.QuotaObserverChore)

Example 2 with SpaceQuotaSnapshot

use of org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot in project hbase by apache.

the class RSRpcServices method getSpaceQuotaSnapshots.

@Override
public GetSpaceQuotaSnapshotsResponse getSpaceQuotaSnapshots(RpcController controller, GetSpaceQuotaSnapshotsRequest request) throws ServiceException {
    try {
        final RegionServerSpaceQuotaManager manager = server.getRegionServerSpaceQuotaManager();
        final GetSpaceQuotaSnapshotsResponse.Builder builder = GetSpaceQuotaSnapshotsResponse.newBuilder();
        if (manager != null) {
            final Map<TableName, SpaceQuotaSnapshot> snapshots = manager.copyQuotaSnapshots();
            for (Entry<TableName, SpaceQuotaSnapshot> snapshot : snapshots.entrySet()) {
                builder.addSnapshots(TableQuotaSnapshot.newBuilder().setTableName(ProtobufUtil.toProtoTableName(snapshot.getKey())).setSnapshot(SpaceQuotaSnapshot.toProtoSnapshot(snapshot.getValue())).build());
            }
        }
        return builder.build();
    } catch (Exception e) {
        throw new ServiceException(e);
    }
}
Also used : SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) TableName(org.apache.hadoop.hbase.TableName) RegionServerSpaceQuotaManager(org.apache.hadoop.hbase.quotas.RegionServerSpaceQuotaManager) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) FailedSanityCheckException(org.apache.hadoop.hbase.exceptions.FailedSanityCheckException) ResultOrException(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException) ScannerResetException(org.apache.hadoop.hbase.exceptions.ScannerResetException) OutOfOrderScannerNextException(org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException) RegionTooBusyException(org.apache.hadoop.hbase.RegionTooBusyException) IOException(java.io.IOException) LeaseStillHeldException(org.apache.hadoop.hbase.regionserver.LeaseManager.LeaseStillHeldException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) UncheckedIOException(java.io.UncheckedIOException) UnknownScannerException(org.apache.hadoop.hbase.UnknownScannerException) FileNotFoundException(java.io.FileNotFoundException) BindException(java.net.BindException) DroppedSnapshotException(org.apache.hadoop.hbase.DroppedSnapshotException) GetSpaceQuotaSnapshotsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsResponse)

Example 3 with SpaceQuotaSnapshot

use of org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot in project hbase by apache.

the class TestMasterMetricsWrapper method testQuotaSnapshotConversion.

@Test
public void testQuotaSnapshotConversion() {
    MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(TEST_UTIL.getHBaseCluster().getMaster());
    assertEquals(new SimpleImmutableEntry<Long, Long>(1024L, 2048L), info.convertSnapshot(new SpaceQuotaSnapshot(SpaceQuotaStatus.notInViolation(), 1024L, 2048L)));
    assertEquals(new SimpleImmutableEntry<Long, Long>(4096L, 2048L), info.convertSnapshot(new SpaceQuotaSnapshot(new SpaceQuotaStatus(SpaceViolationPolicy.NO_INSERTS), 4096L, 2048L)));
}
Also used : SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) SpaceQuotaStatus(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus) Test(org.junit.Test)

Example 4 with SpaceQuotaSnapshot

use of org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot in project hbase by apache.

the class TestBulkLoadCheckingViolationPolicyEnforcement method testFilesUnderLimit.

@Test
public void testFilesUnderLimit() throws Exception {
    final List<String> paths = new ArrayList<>();
    final List<FileStatus> statuses = new ArrayList<>();
    final long length = 100L * 1024L;
    for (int i = 0; i < 5; i++) {
        String path = "/" + i;
        FileStatus status = mock(FileStatus.class);
        when(fs.getFileStatus(new Path(path))).thenReturn(status);
        when(status.getLen()).thenReturn(length);
        when(status.isFile()).thenReturn(true);
        paths.add(path);
        statuses.add(status);
    }
    // Quota is not in violation now
    SpaceQuotaSnapshot snapshot = new SpaceQuotaSnapshot(SpaceQuotaStatus.notInViolation(), 0, length * 6);
    policy.initialize(rss, tableName, snapshot);
    policy.computeBulkLoadSize(fs, paths);
}
Also used : Path(org.apache.hadoop.fs.Path) SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with SpaceQuotaSnapshot

use of org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot in project hbase by apache.

the class TestBulkLoadCheckingViolationPolicyEnforcement method testOneFileInBatchOverLimit.

@Test(expected = SpaceLimitingException.class)
public void testOneFileInBatchOverLimit() throws Exception {
    final List<String> paths = new ArrayList<>();
    final List<FileStatus> statuses = new ArrayList<>();
    final long length = 1000L * 1024L;
    for (int i = 0; i < 5; i++) {
        String path = "/" + i;
        FileStatus status = mock(FileStatus.class);
        when(fs.getFileStatus(new Path(path))).thenReturn(status);
        when(status.getLen()).thenReturn(length);
        when(status.isFile()).thenReturn(true);
        paths.add(path);
        statuses.add(status);
    }
    // Quota is not in violation now
    SpaceQuotaSnapshot snapshot = new SpaceQuotaSnapshot(SpaceQuotaStatus.notInViolation(), 0, 1024L);
    policy.initialize(rss, tableName, snapshot);
    policy.computeBulkLoadSize(fs, paths);
}
Also used : Path(org.apache.hadoop.fs.Path) SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

SpaceQuotaSnapshot (org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot)10 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 FileStatus (org.apache.hadoop.fs.FileStatus)4 Path (org.apache.hadoop.fs.Path)4 TableName (org.apache.hadoop.hbase.TableName)3 QuotaObserverChore (org.apache.hadoop.hbase.quotas.QuotaObserverChore)3 IOException (java.io.IOException)2 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)2 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)2 SpaceQuotaStatus (org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus)2 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)2 FileNotFoundException (java.io.FileNotFoundException)1 UncheckedIOException (java.io.UncheckedIOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BindException (java.net.BindException)1