use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse in project hbase by apache.
the class MasterRpcServices method getSpaceQuotaRegionSizes.
@Override
public GetSpaceQuotaRegionSizesResponse getSpaceQuotaRegionSizes(RpcController controller, GetSpaceQuotaRegionSizesRequest request) throws ServiceException {
try {
server.checkInitialized();
MasterQuotaManager quotaManager = this.server.getMasterQuotaManager();
GetSpaceQuotaRegionSizesResponse.Builder builder = GetSpaceQuotaRegionSizesResponse.newBuilder();
if (quotaManager != null) {
Map<RegionInfo, Long> regionSizes = quotaManager.snapshotRegionSizes();
Map<TableName, Long> regionSizesByTable = new HashMap<>();
// Translate hregioninfo+long -> tablename+long
for (Entry<RegionInfo, Long> entry : regionSizes.entrySet()) {
final TableName tableName = entry.getKey().getTable();
Long prevSize = regionSizesByTable.get(tableName);
if (prevSize == null) {
prevSize = 0L;
}
regionSizesByTable.put(tableName, prevSize + entry.getValue());
}
// Serialize them into the protobuf
for (Entry<TableName, Long> tableSize : regionSizesByTable.entrySet()) {
builder.addSizes(RegionSizes.newBuilder().setTableName(ProtobufUtil.toProtoTableName(tableSize.getKey())).setSize(tableSize.getValue()).build());
}
return builder.build();
} else {
LOG.debug("Received space quota region size report but HMaster is not ready to process it," + "skipping");
}
return builder.build();
} catch (Exception e) {
throw new ServiceException(e);
}
}
Aggregations