use of org.apache.hadoop.hbase.quotas.MasterQuotaManager in project hbase by apache.
the class MasterRpcServices method reportRegionSpaceUse.
@Override
public RegionSpaceUseReportResponse reportRegionSpaceUse(RpcController controller, RegionSpaceUseReportRequest request) throws ServiceException {
try {
server.checkInitialized();
if (!QuotaUtil.isQuotaEnabled(server.getConfiguration())) {
return RegionSpaceUseReportResponse.newBuilder().build();
}
MasterQuotaManager quotaManager = this.server.getMasterQuotaManager();
if (quotaManager != null) {
final long now = EnvironmentEdgeManager.currentTime();
for (RegionSpaceUse report : request.getSpaceUseList()) {
quotaManager.addRegionSize(ProtobufUtil.toRegionInfo(report.getRegionInfo()), report.getRegionSize(), now);
}
} else {
LOG.debug("Received region space usage report but HMaster is not ready to process it, " + "skipping");
}
return RegionSpaceUseReportResponse.newBuilder().build();
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of org.apache.hadoop.hbase.quotas.MasterQuotaManager 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);
}
}
use of org.apache.hadoop.hbase.quotas.MasterQuotaManager in project hbase by apache.
the class HMaster method initQuotaManager.
private void initQuotaManager() throws IOException {
MasterQuotaManager quotaManager = new MasterQuotaManager(this);
quotaManager.start();
this.quotaManager = quotaManager;
}
Aggregations