HBASE-17403 ClientAsyncPrefetchScanner doesn’t load any data if the MaxResultSize is too small (ChiaPing Tsai)

This commit is contained in:
tedyu 2017-01-04 08:21:25 -08:00
parent 05ab41d1be
commit 63bd8be576
2 changed files with 14 additions and 4 deletions

View File

@ -186,7 +186,7 @@ public class ClientAsyncPrefetchScanner extends ClientScanner {
capacity = DEFAULT_QUEUE_CAPACITY;
}
}
return capacity;
return Math.max(capacity, 1);
}
private boolean prefetchCondition() {
@ -197,11 +197,11 @@ public class ClientAsyncPrefetchScanner extends ClientScanner {
}
private int getCountThreshold() {
return cacheCapacity / 2 ;
return Math.max(cacheCapacity / 2, 1);
}
private long getSizeThreshold() {
return maxScannerResultSize / 2 ;
return Math.max(maxScannerResultSize / 2, 1);
}
private long getCacheSizeInBytes() {

View File

@ -152,11 +152,21 @@ public class TestServerSideScanMetricsFromClientSide {
}
@Test
public void testRowsSeenMetric() throws Exception {
public void testRowsSeenMetricWithSync() throws Exception {
testRowsSeenMetric(false);
}
@Test
public void testRowsSeenMetricWithAsync() throws Exception {
testRowsSeenMetric(true);
}
private void testRowsSeenMetric(boolean async) throws Exception {
// Base scan configuration
Scan baseScan;
baseScan = new Scan();
baseScan.setScanMetricsEnabled(true);
baseScan.setAsyncPrefetch(async);
testRowsSeenMetric(baseScan);
// Test case that only a single result will be returned per RPC to the serer