Search in sources :

Example 1 with GetSpaceQuotaRegionSizesResponse

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

Aggregations

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