|
58 | 58 | import org.junit.AfterClass; |
59 | 59 | import org.junit.BeforeClass; |
60 | 60 | import org.junit.ClassRule; |
61 | | -import org.junit.Ignore; |
62 | 61 | import org.junit.Rule; |
63 | 62 | import org.junit.Test; |
64 | 63 | import org.junit.experimental.categories.Category; |
@@ -292,18 +291,11 @@ public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOE |
292 | 291 | } |
293 | 292 | } |
294 | 293 |
|
295 | | - /** |
296 | | - * TODO: not sure what do we test here but seems the test can not work together with async |
297 | | - * prefetch scanner. Ignore it for now, as after HBASE-21879 is landed we will have a more natural |
298 | | - * way to deal with reference counting... |
299 | | - */ |
300 | | - @Ignore |
301 | 294 | @Test |
302 | 295 | public void testHBASE16372InReadPath() throws Exception { |
303 | 296 | final TableName tableName = TableName.valueOf(name.getMethodName()); |
304 | 297 | // Create a table with block size as 1024 |
305 | | - final Table table = TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024, null); |
306 | | - try { |
| 298 | + try (Table table = TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024, null)) { |
307 | 299 | // get the block cache and region |
308 | 300 | RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName); |
309 | 301 | String regionName = locator.getAllRegionLocations().get(0).getRegion().getEncodedName(); |
@@ -370,7 +362,8 @@ public void testHBASE16372InReadPath() throws Exception { |
370 | 362 | // set partial as true so that the scan can send partial columns also |
371 | 363 | s.setAllowPartialResults(true); |
372 | 364 | s.setMaxResultSize(1000); |
373 | | - try (ResultScanner scanner = table.getScanner(s)) { |
| 365 | + try (ScanPerNextResultScanner scanner = |
| 366 | + new ScanPerNextResultScanner(TEST_UTIL.getAsyncConnection().getTable(tableName), s)) { |
374 | 367 | Thread evictorThread = new Thread() { |
375 | 368 | @Override |
376 | 369 | public void run() { |
@@ -402,9 +395,8 @@ public void run() { |
402 | 395 | s1.withStartRow(ROW3); |
403 | 396 | s1.withStopRow(ROW5); |
404 | 397 | s1.setCaching(1); |
405 | | - ResultScanner scanner; |
406 | | - try { |
407 | | - scanner = table.getScanner(s1); |
| 398 | + |
| 399 | + try (ResultScanner scanner = table.getScanner(s1)) { |
408 | 400 | int count = Iterables.size(scanner); |
409 | 401 | assertEquals("Count the rows", 2, count); |
410 | 402 | int newBlockRefCount = 0; |
@@ -442,8 +434,6 @@ public void run() { |
442 | 434 | } |
443 | 435 | } |
444 | 436 | assertEquals("Count should give all rows ", 10, count); |
445 | | - } finally { |
446 | | - table.close(); |
447 | 437 | } |
448 | 438 | } |
449 | 439 | } |
0 commit comments