Search in sources :

Example 1 with RegionSpaceUseReportRequest

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

the class HRegionServer method buildReportAndSend.

/**
 * Builds the region size report and sends it to the master. Upon successful sending of the
 * report, the region sizes that were sent are marked as sent.
 *
 * @param rss The stub to send to the Master
 * @param regionSizeStore The store containing region sizes
 */
private void buildReportAndSend(RegionServerStatusService.BlockingInterface rss, RegionSizeStore regionSizeStore) throws ServiceException {
    RegionSpaceUseReportRequest request = buildRegionSpaceUseReportRequest(Objects.requireNonNull(regionSizeStore));
    rss.reportRegionSpaceUse(null, request);
    // Record the number of size reports sent
    if (metricsRegionServer != null) {
        metricsRegionServer.incrementNumRegionSizeReportsSent(regionSizeStore.size());
    }
}
Also used : RegionSpaceUseReportRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest)

Example 2 with RegionSpaceUseReportRequest

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

Aggregations

RegionSpaceUseReportRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest)2 TableName (org.apache.hadoop.hbase.TableName)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 RegionSize (org.apache.hadoop.hbase.quotas.RegionSize)1 RegionSizeStore (org.apache.hadoop.hbase.quotas.RegionSizeStore)1 RegionSpaceUse (org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse)1 Test (org.junit.Test)1