Search in sources :

Example 1 with RegionSpaceUse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse in project hbase by apache.

the class TestRegionServerRegionSpaceUseReport method testConversion.

@Test
public void testConversion() {
    TableName tn = TableName.valueOf("table1");
    RegionInfo hri1 = RegionInfoBuilder.newBuilder(tn).setStartKey(Bytes.toBytes("a")).setEndKey(Bytes.toBytes("b")).build();
    RegionInfo hri2 = RegionInfoBuilder.newBuilder(tn).setStartKey(Bytes.toBytes("b")).setEndKey(Bytes.toBytes("c")).build();
    RegionInfo hri3 = RegionInfoBuilder.newBuilder(tn).setStartKey(Bytes.toBytes("c")).setEndKey(Bytes.toBytes("d")).build();
    RegionSizeStore store = RegionSizeStoreFactory.getInstance().createStore();
    store.put(hri1, 1024L * 1024L);
    store.put(hri2, 1024L * 1024L * 8L);
    store.put(hri3, 1024L * 1024L * 32L);
    // Call the real method to convert the map into a protobuf
    HRegionServer rs = mock(HRegionServer.class);
    doCallRealMethod().when(rs).buildRegionSpaceUseReportRequest(any(RegionSizeStore.class));
    doCallRealMethod().when(rs).convertRegionSize(any(), anyLong());
    RegionSpaceUseReportRequest requests = rs.buildRegionSpaceUseReportRequest(store);
    assertEquals(store.size(), requests.getSpaceUseCount());
    for (RegionSpaceUse spaceUse : requests.getSpaceUseList()) {
        RegionInfo hri = ProtobufUtil.toRegionInfo(spaceUse.getRegionInfo());
        RegionSize expectedSize = store.remove(hri);
        assertNotNull("Could not find size for HRI: " + hri, expectedSize);
        assertEquals(expectedSize.getSize(), spaceUse.getRegionSize());
    }
    assertTrue("Should not have any space use entries left: " + store, store.isEmpty());
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RegionSpaceUse(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse) RegionSizeStore(org.apache.hadoop.hbase.quotas.RegionSizeStore) RegionSpaceUseReportRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest) RegionSize(org.apache.hadoop.hbase.quotas.RegionSize) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Example 2 with RegionSpaceUse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse 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)

Aggregations

RegionSpaceUse (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)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 RegionSize (org.apache.hadoop.hbase.quotas.RegionSize)1 RegionSizeStore (org.apache.hadoop.hbase.quotas.RegionSizeStore)1 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)1 RegionSpaceUseReportRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1 KeeperException (org.apache.zookeeper.KeeperException)1 Test (org.junit.Test)1