HBASE-13369 Expose scanNext stats to region server level
This commit is contained in:
parent
619d34487e
commit
64941c6151
|
@ -87,6 +87,13 @@ public interface MetricsRegionServerSource extends BaseSource {
|
||||||
*/
|
*/
|
||||||
void updateReplay(long t);
|
void updateReplay(long t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the scan size.
|
||||||
|
*
|
||||||
|
* @param scanSize size of the scan
|
||||||
|
*/
|
||||||
|
void updateScannerNext(long scanSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment the number of slow Puts that have happened.
|
* Increment the number of slow Puts that have happened.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class MetricsRegionServerSourceImpl
|
||||||
private final MetricHistogram incrementHisto;
|
private final MetricHistogram incrementHisto;
|
||||||
private final MetricHistogram appendHisto;
|
private final MetricHistogram appendHisto;
|
||||||
private final MetricHistogram replayHisto;
|
private final MetricHistogram replayHisto;
|
||||||
|
private final MetricHistogram scanNextHisto;
|
||||||
|
|
||||||
private final MutableCounterLong slowPut;
|
private final MutableCounterLong slowPut;
|
||||||
private final MutableCounterLong slowDelete;
|
private final MutableCounterLong slowDelete;
|
||||||
|
@ -82,6 +83,7 @@ public class MetricsRegionServerSourceImpl
|
||||||
slowAppend = getMetricsRegistry().newCounter(SLOW_APPEND_KEY, SLOW_APPEND_DESC, 0l);
|
slowAppend = getMetricsRegistry().newCounter(SLOW_APPEND_KEY, SLOW_APPEND_DESC, 0l);
|
||||||
|
|
||||||
replayHisto = getMetricsRegistry().newHistogram(REPLAY_KEY);
|
replayHisto = getMetricsRegistry().newHistogram(REPLAY_KEY);
|
||||||
|
scanNextHisto = getMetricsRegistry().newHistogram(SCAN_NEXT_KEY);
|
||||||
|
|
||||||
splitTimeHisto = getMetricsRegistry().newHistogram(SPLIT_KEY);
|
splitTimeHisto = getMetricsRegistry().newHistogram(SPLIT_KEY);
|
||||||
flushTimeHisto = getMetricsRegistry().newHistogram(FLUSH_KEY);
|
flushTimeHisto = getMetricsRegistry().newHistogram(FLUSH_KEY);
|
||||||
|
@ -120,6 +122,11 @@ public class MetricsRegionServerSourceImpl
|
||||||
replayHisto.add(t);
|
replayHisto.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScannerNext(long scanSize) {
|
||||||
|
scanNextHisto.add(scanSize);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrSlowPut() {
|
public void incrSlowPut() {
|
||||||
slowPut.incr();
|
slowPut.incr();
|
||||||
|
|
|
@ -95,6 +95,10 @@ public class MetricsRegionServer {
|
||||||
serverSource.updateReplay(t);
|
serverSource.updateReplay(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateScannerNext(long scanSize){
|
||||||
|
serverSource.updateScannerNext(scanSize);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateSplitTime(long t) {
|
public void updateSplitTime(long t) {
|
||||||
serverSource.updateSplitTime(t);
|
serverSource.updateSplitTime(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2294,6 +2294,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||||
}
|
}
|
||||||
region.updateReadRequestsCount(i);
|
region.updateReadRequestsCount(i);
|
||||||
region.getMetrics().updateScanNext(totalCellSize);
|
region.getMetrics().updateScanNext(totalCellSize);
|
||||||
|
if (regionServer.metricsRegionServer != null) {
|
||||||
|
regionServer.metricsRegionServer.updateScannerNext(totalCellSize);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
region.closeRegionOperation();
|
region.closeRegionOperation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class TestRegionServerMetrics {
|
||||||
private static HBaseTestingUtility TEST_UTIL;
|
private static HBaseTestingUtility TEST_UTIL;
|
||||||
private static MetricsRegionServer metricsRegionServer;
|
private static MetricsRegionServer metricsRegionServer;
|
||||||
private static MetricsRegionServerSource serverSource;
|
private static MetricsRegionServerSource serverSource;
|
||||||
|
private static final int NUM_SCAN_NEXT = 30;
|
||||||
|
private static int numScanNext = 0;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void startCluster() throws Exception {
|
public static void startCluster() throws Exception {
|
||||||
|
@ -329,7 +331,6 @@ public class TestRegionServerMetrics {
|
||||||
byte[] qualifier = Bytes.toBytes("qual");
|
byte[] qualifier = Bytes.toBytes("qual");
|
||||||
byte[] val = Bytes.toBytes("One");
|
byte[] val = Bytes.toBytes("One");
|
||||||
|
|
||||||
|
|
||||||
List<Put> puts = new ArrayList<>();
|
List<Put> puts = new ArrayList<>();
|
||||||
for (int insertCount =0; insertCount < 100; insertCount++) {
|
for (int insertCount =0; insertCount < 100; insertCount++) {
|
||||||
Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
|
Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
|
||||||
|
@ -344,12 +345,13 @@ public class TestRegionServerMetrics {
|
||||||
s.setCaching(1);
|
s.setCaching(1);
|
||||||
ResultScanner resultScanners = t.getScanner(s);
|
ResultScanner resultScanners = t.getScanner(s);
|
||||||
|
|
||||||
for (int nextCount = 0; nextCount < 30; nextCount++) {
|
for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
|
||||||
Result result = resultScanners.next();
|
Result result = resultScanners.next();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals(1, result.size());
|
assertEquals(1, result.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
numScanNext += NUM_SCAN_NEXT;
|
||||||
try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
|
try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
|
||||||
for ( HRegionLocation location: locator.getAllRegionLocations()) {
|
for ( HRegionLocation location: locator.getAllRegionLocations()) {
|
||||||
HRegionInfo i = location.getRegionInfo();
|
HRegionInfo i = location.getRegionInfo();
|
||||||
|
@ -361,8 +363,55 @@ public class TestRegionServerMetrics {
|
||||||
"_table_"+tableNameString +
|
"_table_"+tableNameString +
|
||||||
"_region_" + i.getEncodedName()+
|
"_region_" + i.getEncodedName()+
|
||||||
"_metric";
|
"_metric";
|
||||||
metricsHelper.assertCounter(prefix + "_scanNextNumOps", 30, agg);
|
metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
|
||||||
}
|
}
|
||||||
|
metricsHelper.assertCounter("ScanNext_num_ops", numScanNext, serverSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testScanNextForSmallScan() throws IOException {
|
||||||
|
String tableNameString = "testScanNextSmall";
|
||||||
|
TableName tableName = TableName.valueOf(tableNameString);
|
||||||
|
byte[] cf = Bytes.toBytes("d");
|
||||||
|
byte[] qualifier = Bytes.toBytes("qual");
|
||||||
|
byte[] val = Bytes.toBytes("One");
|
||||||
|
|
||||||
|
List<Put> puts = new ArrayList<>();
|
||||||
|
for (int insertCount =0; insertCount < 100; insertCount++) {
|
||||||
|
Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
|
||||||
|
p.add(cf, qualifier, val);
|
||||||
|
puts.add(p);
|
||||||
|
}
|
||||||
|
try (HTable t = TEST_UTIL.createTable(tableName, cf)) {
|
||||||
|
t.put(puts);
|
||||||
|
|
||||||
|
Scan s = new Scan();
|
||||||
|
s.setSmall(true);
|
||||||
|
s.setCaching(1);
|
||||||
|
ResultScanner resultScanners = t.getScanner(s);
|
||||||
|
|
||||||
|
for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
|
||||||
|
Result result = resultScanners.next();
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals(1, result.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
numScanNext += NUM_SCAN_NEXT;
|
||||||
|
try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
|
||||||
|
for ( HRegionLocation location: locator.getAllRegionLocations()) {
|
||||||
|
HRegionInfo i = location.getRegionInfo();
|
||||||
|
MetricsRegionAggregateSource agg = rs.getRegion(i.getRegionName())
|
||||||
|
.getMetrics()
|
||||||
|
.getSource()
|
||||||
|
.getAggregateSource();
|
||||||
|
String prefix = "namespace_"+NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR+
|
||||||
|
"_table_"+tableNameString +
|
||||||
|
"_region_" + i.getEncodedName()+
|
||||||
|
"_metric";
|
||||||
|
metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
|
||||||
|
}
|
||||||
|
metricsHelper.assertCounter("ScanNext_num_ops", numScanNext, serverSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue