Search in sources :

Example 1 with MasterQuotaManager

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);
    }
}
Also used : RegionSpaceUse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse) MasterQuotaManager(org.apache.hadoop.hbase.quotas.MasterQuotaManager) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) IOException(java.io.IOException) RemoteProcedureException(org.apache.hadoop.hbase.procedure2.RemoteProcedureException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) KeeperException(org.apache.zookeeper.KeeperException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with MasterQuotaManager

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);
    }
}
Also used : MasterQuotaManager(org.apache.hadoop.hbase.quotas.MasterQuotaManager) HashMap(java.util.HashMap) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) IOException(java.io.IOException) RemoteProcedureException(org.apache.hadoop.hbase.procedure2.RemoteProcedureException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) KeeperException(org.apache.zookeeper.KeeperException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TableName(org.apache.hadoop.hbase.TableName) GetSpaceQuotaRegionSizesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)

Example 3 with MasterQuotaManager

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;
}
Also used : MasterQuotaManager(org.apache.hadoop.hbase.quotas.MasterQuotaManager)

Aggregations

MasterQuotaManager (org.apache.hadoop.hbase.quotas.MasterQuotaManager)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)2 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)2 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)2 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)2 RemoteProcedureException (org.apache.hadoop.hbase.procedure2.RemoteProcedureException)2 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)2 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)2 KeeperException (org.apache.zookeeper.KeeperException)2 HashMap (java.util.HashMap)1 TableName (org.apache.hadoop.hbase.TableName)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 GetSpaceQuotaRegionSizesResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse)1 RegionSpaceUse (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse)1