HBASE-13312 SmallScannerCallable does not increment scan metrics

This commit is contained in:
Andrew Purtell 2015-05-01 16:33:14 -07:00
parent 58689b4a00
commit a6027aedb3
3 changed files with 36 additions and 1 deletions

View File

@ -207,6 +207,8 @@ public class ClientSmallScanner extends ClientScanner {
} else { } else {
setHasMoreResultsContext(false); setHasMoreResultsContext(false);
} }
// We need to update result metrics since we are overriding call()
updateResultsMetrics(results);
return results; return results;
} catch (ServiceException se) { } catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se); throw ProtobufUtil.getRemoteException(se);

View File

@ -325,7 +325,7 @@ public class ScannerCallable extends RegionServerCallable<Result[]> {
} }
} }
private void updateResultsMetrics(Result[] rrs) { protected void updateResultsMetrics(Result[] rrs) {
if (this.scanMetrics == null || rrs == null || rrs.length == 0) { if (this.scanMetrics == null || rrs == null || rrs.length == 0) {
return; return;
} }

View File

@ -5004,6 +5004,39 @@ public class TestFromClientSide {
assertEquals("Did not access all the regions in the table", numOfRegions, assertEquals("Did not access all the regions in the table", numOfRegions,
scanMetrics.countOfRegions.get()); scanMetrics.countOfRegions.get());
// check byte counters
scan2 = new Scan();
scan2.setScanMetricsEnabled(true);
scan2.setCaching(1);
scanner = ht.getScanner(scan2);
int numBytes = 0;
for (Result result : scanner.next(1)) {
for (Cell cell: result.listCells()) {
numBytes += CellUtil.estimatedSerializedSizeOf(cell);
}
}
scanner.close();
scanMetrics = scan2.getScanMetrics();
assertEquals("Did not count the result bytes", numBytes,
scanMetrics.countOfBytesInResults.get());
// check byte counters on a small scan
scan2 = new Scan();
scan2.setScanMetricsEnabled(true);
scan2.setCaching(1);
scan2.setSmall(true);
scanner = ht.getScanner(scan2);
numBytes = 0;
for (Result result : scanner.next(1)) {
for (Cell cell: result.listCells()) {
numBytes += CellUtil.estimatedSerializedSizeOf(cell);
}
}
scanner.close();
scanMetrics = scan2.getScanMetrics();
assertEquals("Did not count the result bytes", numBytes,
scanMetrics.countOfBytesInResults.get());
// now, test that the metrics are still collected even if you don't call close, but do // now, test that the metrics are still collected even if you don't call close, but do
// run past the end of all the records // run past the end of all the records
/** There seems to be a timing issue here. Comment out for now. Fix when time. /** There seems to be a timing issue here. Comment out for now. Fix when time.