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;
}
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);
}
}
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)));
}
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);
}
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);
}
Aggregations