HBASE-15412 Add average region size metric (Alicia Ying Shu)
Conflicts: hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java
This commit is contained in:
parent
2331d9efe3
commit
d07230a759
|
@ -422,4 +422,7 @@ public interface MetricsRegionServerSource extends BaseSource {
|
||||||
String RPC_MUTATE_REQUEST_COUNT = "rpcMutateRequestCount";
|
String RPC_MUTATE_REQUEST_COUNT = "rpcMutateRequestCount";
|
||||||
String RPC_MUTATE_REQUEST_COUNT_DESC =
|
String RPC_MUTATE_REQUEST_COUNT_DESC =
|
||||||
"Number of rpc mutation requests this region server has answered.";
|
"Number of rpc mutation requests this region server has answered.";
|
||||||
|
String AVERAGE_REGION_SIZE = "averageRegionSize";
|
||||||
|
String AVERAGE_REGION_SIZE_DESC =
|
||||||
|
"Average region size over the region server including memstore and storefile sizes.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,4 +322,9 @@ public interface MetricsRegionServerWrapper {
|
||||||
* Get the number of rpc mutate requests to this region server.
|
* Get the number of rpc mutate requests to this region server.
|
||||||
*/
|
*/
|
||||||
long getRpcMutateRequestsCount();
|
long getRpcMutateRequestsCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the average region size to this region server.
|
||||||
|
*/
|
||||||
|
long getAverageRegionSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,6 +328,7 @@ public class MetricsRegionServerSourceImpl
|
||||||
rsWrap.getNumReferenceFiles())
|
rsWrap.getNumReferenceFiles())
|
||||||
.addGauge(Interns.info(RS_START_TIME_NAME, RS_START_TIME_DESC),
|
.addGauge(Interns.info(RS_START_TIME_NAME, RS_START_TIME_DESC),
|
||||||
rsWrap.getStartCode())
|
rsWrap.getStartCode())
|
||||||
|
.addGauge(Interns.info(AVERAGE_REGION_SIZE, AVERAGE_REGION_SIZE_DESC), rsWrap.getAverageRegionSize())
|
||||||
.addCounter(Interns.info(TOTAL_REQUEST_COUNT, TOTAL_REQUEST_COUNT_DESC),
|
.addCounter(Interns.info(TOTAL_REQUEST_COUNT, TOTAL_REQUEST_COUNT_DESC),
|
||||||
rsWrap.getTotalRequestCount())
|
rsWrap.getTotalRequestCount())
|
||||||
.addCounter(Interns.info(READ_REQUEST_COUNT, READ_REQUEST_COUNT_DESC),
|
.addCounter(Interns.info(READ_REQUEST_COUNT, READ_REQUEST_COUNT_DESC),
|
||||||
|
@ -412,7 +413,6 @@ public class MetricsRegionServerSourceImpl
|
||||||
rsWrap.getCompactedCellsSize())
|
rsWrap.getCompactedCellsSize())
|
||||||
.addCounter(Interns.info(MAJOR_COMPACTED_CELLS_SIZE, MAJOR_COMPACTED_CELLS_SIZE_DESC),
|
.addCounter(Interns.info(MAJOR_COMPACTED_CELLS_SIZE, MAJOR_COMPACTED_CELLS_SIZE_DESC),
|
||||||
rsWrap.getMajorCompactedCellsSize())
|
rsWrap.getMajorCompactedCellsSize())
|
||||||
|
|
||||||
.addCounter(Interns.info(BLOCKED_REQUESTS_COUNT, BLOCKED_REQUESTS_COUNT_DESC),
|
.addCounter(Interns.info(BLOCKED_REQUESTS_COUNT, BLOCKED_REQUESTS_COUNT_DESC),
|
||||||
rsWrap.getBlockedRequestsCount())
|
rsWrap.getBlockedRequestsCount())
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ class MetricsRegionServerWrapperImpl
|
||||||
private volatile long compactedCellsSize = 0;
|
private volatile long compactedCellsSize = 0;
|
||||||
private volatile long majorCompactedCellsSize = 0;
|
private volatile long majorCompactedCellsSize = 0;
|
||||||
private volatile long blockedRequestsCount = 0L;
|
private volatile long blockedRequestsCount = 0L;
|
||||||
|
private volatile long averageRegionSize = 0L;
|
||||||
|
|
||||||
private CacheStats cacheStats;
|
private CacheStats cacheStats;
|
||||||
private ScheduledExecutorService executor;
|
private ScheduledExecutorService executor;
|
||||||
|
@ -538,6 +539,7 @@ class MetricsRegionServerWrapperImpl
|
||||||
long tempMajorCompactedCellsSize = 0;
|
long tempMajorCompactedCellsSize = 0;
|
||||||
long tempBlockedRequestsCount = 0L;
|
long tempBlockedRequestsCount = 0L;
|
||||||
|
|
||||||
|
int regionCount = 0;
|
||||||
for (Region r : regionServer.getOnlineRegionsLocalContext()) {
|
for (Region r : regionServer.getOnlineRegionsLocalContext()) {
|
||||||
tempNumMutationsWithoutWAL += r.getNumMutationsWithoutWAL();
|
tempNumMutationsWithoutWAL += r.getNumMutationsWithoutWAL();
|
||||||
tempDataInMemoryWithoutWAL += r.getDataInMemoryWithoutWAL();
|
tempDataInMemoryWithoutWAL += r.getDataInMemoryWithoutWAL();
|
||||||
|
@ -582,6 +584,7 @@ class MetricsRegionServerWrapperImpl
|
||||||
if (r.getRegionInfo().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
|
if (r.getRegionInfo().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
|
||||||
hdfsBlocksDistributionSecondaryRegions.add(distro);
|
hdfsBlocksDistributionSecondaryRegions.add(distro);
|
||||||
}
|
}
|
||||||
|
regionCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
float localityIndex =
|
float localityIndex =
|
||||||
|
@ -627,6 +630,9 @@ class MetricsRegionServerWrapperImpl
|
||||||
memstoreSize = tempMemstoreSize;
|
memstoreSize = tempMemstoreSize;
|
||||||
storeFileSize = tempStoreFileSize;
|
storeFileSize = tempStoreFileSize;
|
||||||
maxStoreFileAge = tempMaxStoreFileAge;
|
maxStoreFileAge = tempMaxStoreFileAge;
|
||||||
|
if (regionCount > 0) {
|
||||||
|
averageRegionSize = (memstoreSize + storeFileSize) / regionCount;
|
||||||
|
}
|
||||||
if (tempMinStoreFileAge != Long.MAX_VALUE) {
|
if (tempMinStoreFileAge != Long.MAX_VALUE) {
|
||||||
minStoreFileAge = tempMinStoreFileAge;
|
minStoreFileAge = tempMinStoreFileAge;
|
||||||
}
|
}
|
||||||
|
@ -664,4 +670,10 @@ class MetricsRegionServerWrapperImpl
|
||||||
public long getBlockedRequestsCount() {
|
public long getBlockedRequestsCount() {
|
||||||
return blockedRequestsCount;
|
return blockedRequestsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAverageRegionSize() {
|
||||||
|
return averageRegionSize;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,4 +314,9 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
|
||||||
public int getSplitQueueSize() {
|
public int getSplitQueueSize() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAverageRegionSize() {
|
||||||
|
return 10000000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,4 +625,25 @@ public class TestRegionServerMetrics {
|
||||||
|
|
||||||
table.close();
|
table.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAverageRegionSize() throws Exception {
|
||||||
|
TableName tableName = TableName.valueOf("testAverageRegionSize");
|
||||||
|
byte[] cf = Bytes.toBytes("d");
|
||||||
|
byte[] row = Bytes.toBytes("rk");
|
||||||
|
byte[] qualifier = Bytes.toBytes("qual");
|
||||||
|
byte[] val = Bytes.toBytes("Value");
|
||||||
|
|
||||||
|
//Force a hfile.
|
||||||
|
Table t = TEST_UTIL.createTable(tableName, cf);
|
||||||
|
Put p = new Put(row);
|
||||||
|
p.addColumn(cf, qualifier, val);
|
||||||
|
t.put(p);
|
||||||
|
TEST_UTIL.getHBaseAdmin().flush(tableName);
|
||||||
|
|
||||||
|
metricsRegionServer.getRegionServerWrapper().forceRecompute();
|
||||||
|
assertTrue(metricsHelper.getGaugeDouble("averageRegionSize", serverSource) > 0.0);
|
||||||
|
|
||||||
|
t.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue