From 1635eb624de5a77e4abd6535fe453e70c1caf5b1 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Tue, 1 Mar 2022 21:22:22 -0500 Subject: [PATCH 1/7] HBASE-26784 Use HIGH_QOS for ResultScanner.close requests --- ...syncScanSingleRegionRpcRetryingCaller.java | 3 +- .../client/TestAsyncTableRpcPriority.java | 63 +++++++++++++------ 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java index 1fa3c81e5d1d..7f19180a0ab2 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.java @@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit; import org.apache.hadoop.hbase.CallQueueTooBigException; import org.apache.hadoop.hbase.DoNotRetryIOException; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.UnknownScannerException; @@ -347,7 +348,7 @@ private long remainingTimeNs() { private void closeScanner() { incRPCCallsMetrics(scanMetrics, regionServerRemote); - resetController(controller, rpcTimeoutNs, priority); + resetController(controller, rpcTimeoutNs, HConstants.HIGH_QOS); ScanRequest req = RequestConverter.buildScanRequest(this.scannerId, 0, true, false); stub.scan(controller, req, resp -> { if (controller.failed()) { diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index b1047985eb6e..77f71d88b622 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HConstants.HIGH_QOS; import static org.apache.hadoop.hbase.HConstants.NORMAL_QOS; import static org.apache.hadoop.hbase.HConstants.SYSTEMTABLE_QOS; import static org.apache.hadoop.hbase.NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR; @@ -218,6 +219,16 @@ public boolean matches(HBaseRpcController controller) { }); } + private ScanRequest assertScannerCloseRequest() { + return argThat(new ArgumentMatcher() { + + @Override + public boolean matches(ScanRequest request) { + return request.hasCloseScanner() && request.getCloseScanner(); + } + }); + } + @Test public void testGet() { conn.getTable(TableName.valueOf(name.getMethodName())) @@ -481,50 +492,66 @@ public void testCheckAndMutateMetaTable() throws IOException { @Test public void testScan() throws IOException, InterruptedException { try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setPriority(19))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); + .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setPriority(19).setLimit(10))) { + for (Result result : scanner) { + assertNotNull(result); + Thread.sleep(1000); + } } Thread.sleep(1000); - // open, next, several renew lease, and then close - verify(stub, atLeast(4)).scan(assertPriority(19), any(ScanRequest.class), any()); + // open, next, then several renew lease + verify(stub, atLeast(3)).scan(assertPriority(19), any(ScanRequest.class), any()); + // close should use high qos + verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); } @Test public void testScanNormalTable() throws IOException, InterruptedException { try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); + .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setLimit(10))) { + for (Result result : scanner) { + assertNotNull(result); + Thread.sleep(1000); + } } Thread.sleep(1000); - // open, next, several renew lease, and then close - verify(stub, atLeast(4)).scan(assertPriority(NORMAL_QOS), any(ScanRequest.class), any()); + // open, next, then several renew lease + verify(stub, atLeast(3)).scan(assertPriority(NORMAL_QOS), any(ScanRequest.class), any()); + // close should use high qos + verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); } @Test public void testScanSystemTable() throws IOException, InterruptedException { try (ResultScanner scanner = conn.getTable(TableName.valueOf(SYSTEM_NAMESPACE_NAME_STR, name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); + .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setLimit(10))) { + for (Result result : scanner) { + assertNotNull(result); + Thread.sleep(1000); + } } Thread.sleep(1000); - // open, next, several renew lease, and then close - verify(stub, atLeast(4)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); + // open, next, then several renew lease + verify(stub, atLeast(3)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); + // close should use high qos + verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); } @Test public void testScanMetaTable() throws IOException, InterruptedException { try (ResultScanner scanner = conn.getTable(TableName.META_TABLE_NAME) .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); + for (Result result : scanner) { + assertNotNull(result); + Thread.sleep(1000); + } } Thread.sleep(1000); // open, next, several renew lease, and then close - verify(stub, atLeast(4)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); + verify(stub, atLeast(3)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); + // close should use high qos + verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); } @Test From a5ab3ce350c9cc919dfd759f10c417f7a58ada61 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Thu, 3 Mar 2022 09:09:10 -0500 Subject: [PATCH 2/7] Add test case to AbstractTestAsyncTableScan suite for testing closing of a scan prematurely --- .../client/AbstractTestAsyncTableScan.java | 38 ++++++++--- .../hbase/client/TestAsyncTableScan.java | 68 +++++++++++++++++-- .../hbase/client/TestAsyncTableScanAll.java | 7 +- .../hbase/client/TestAsyncTableScanner.java | 11 ++- .../hbase/client/TestRawAsyncTableScan.java | 11 ++- 5 files changed, 119 insertions(+), 16 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java index c34f87279495..58aa602591ea 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java @@ -129,7 +129,7 @@ protected static List getTableAndScanCreatorParams() { protected abstract Scan createScan(); - protected abstract List doScan(Scan scan) throws Exception; + protected abstract List doScan(Scan scan, int closeAfter) throws Exception; protected final List convertFromBatchResult(List results) { assertTrue(results.size() % 2 == 0); @@ -145,7 +145,7 @@ protected final List convertFromBatchResult(List results) { @Test public void testScanAll() throws Exception { - List results = doScan(createScan()); + List results = doScan(createScan(), -1); // make sure all scanners are closed at RS side TEST_UTIL.getHBaseCluster().getRegionServerThreads().stream().map(t -> t.getRegionServer()) .forEach( @@ -169,7 +169,7 @@ private void assertResultEquals(Result result, int i) { @Test public void testReversedScanAll() throws Exception { - List results = doScan(createScan().setReversed(true)); + List results = doScan(createScan().setReversed(true), -1); assertEquals(COUNT, results.size()); IntStream.range(0, COUNT).forEach(i -> assertResultEquals(results.get(i), COUNT - i - 1)); } @@ -178,7 +178,7 @@ public void testReversedScanAll() throws Exception { public void testScanNoStopKey() throws Exception { int start = 345; List results = - doScan(createScan().withStartRow(Bytes.toBytes(String.format("%03d", start)))); + doScan(createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))), -1); assertEquals(COUNT - start, results.size()); IntStream.range(0, COUNT - start).forEach(i -> assertResultEquals(results.get(i), start + i)); } @@ -187,7 +187,7 @@ public void testScanNoStopKey() throws Exception { public void testReverseScanNoStopKey() throws Exception { int start = 765; List results = doScan( - createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))).setReversed(true)); + createScan().withStartRow(Bytes.toBytes(String.format("%03d", start))).setReversed(true), -1); assertEquals(start + 1, results.size()); IntStream.range(0, start + 1).forEach(i -> assertResultEquals(results.get(i), start - i)); } @@ -195,7 +195,7 @@ public void testReverseScanNoStopKey() throws Exception { @Test public void testScanWrongColumnFamily() throws Exception { try { - doScan(createScan().addFamily(Bytes.toBytes("WrongColumnFamily"))); + doScan(createScan().addFamily(Bytes.toBytes("WrongColumnFamily")), -1); } catch (Exception e) { assertTrue(e instanceof NoSuchColumnFamilyException || e.getCause() instanceof NoSuchColumnFamilyException); @@ -203,20 +203,28 @@ public void testScanWrongColumnFamily() throws Exception { } private void testScan(int start, boolean startInclusive, int stop, boolean stopInclusive, - int limit) throws Exception { + int limit) throws Exception { + testScan(start, startInclusive, stop, stopInclusive, limit, -1); + } + + private void testScan(int start, boolean startInclusive, int stop, boolean stopInclusive, + int limit, int closeAfter) throws Exception { Scan scan = createScan().withStartRow(Bytes.toBytes(String.format("%03d", start)), startInclusive) .withStopRow(Bytes.toBytes(String.format("%03d", stop)), stopInclusive); if (limit > 0) { scan.setLimit(limit); } - List results = doScan(scan); + List results = doScan(scan, closeAfter); int actualStart = startInclusive ? start : start + 1; int actualStop = stopInclusive ? stop + 1 : stop; int count = actualStop - actualStart; if (limit > 0) { count = Math.min(count, limit); } + if (closeAfter > 0) { + count = Math.min(count, closeAfter); + } assertEquals(count, results.size()); IntStream.range(0, count).forEach(i -> assertResultEquals(results.get(i), actualStart + i)); } @@ -229,12 +237,15 @@ private void testReversedScan(int start, boolean startInclusive, int stop, boole if (limit > 0) { scan.setLimit(limit); } - List results = doScan(scan); + List results = doScan(scan, -1); int actualStart = startInclusive ? start : start - 1; int actualStop = stopInclusive ? stop - 1 : stop; int count = actualStart - actualStop; if (limit > 0) { count = Math.min(count, limit); + } + if (scan.getBatch() > 0) { + } assertEquals(count, results.size()); IntStream.range(0, count).forEach(i -> assertResultEquals(results.get(i), actualStart - i)); @@ -309,4 +320,13 @@ public void testReversedScanWithLimitGreaterThanActualCount() throws Exception { testReversedScan(765, false, 543, true, 200); testReversedScan(876, false, 654, false, 200); } + + @Test + public void testScanEndingEarly() throws Exception { + testScan(1, true, 998, false, 0, 900); // from first region to last region + testScan(123, true, 234, true, 0, 100); + testScan(234, true, 456, false, 0, 100); + testScan(345, false, 567, true, 0, 100); + testScan(456, false, 678, false, 0, 100); + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java index 42d2c38376d6..04aaba1deacb 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java @@ -17,12 +17,14 @@ */ package org.apache.hadoop.hbase.client; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.ForkJoinPool; import java.util.function.Supplier; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hbase.thirdparty.com.google.common.base.Throwables; import org.junit.ClassRule; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -55,16 +57,74 @@ protected Scan createScan() { } @Override - protected List doScan(Scan scan) throws Exception { + protected List doScan(Scan scan, int closeAfter) throws Exception { AsyncTable table = ASYNC_CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool()); - SimpleScanResultConsumer consumer = new SimpleScanResultConsumer(); - table.scan(scan, consumer); - List results = consumer.getAll(); + List results; + if (closeAfter > 0) { + // these tests batch settings with the sample data result in each result being + // split in two. so we must allow twice the expected results in order to reach + // our true limit. see convertFromBatchResult for details. + if (scan.getBatch() > 0) { + closeAfter = closeAfter * 2; + } + LimitedScanResultConsumer consumer = new LimitedScanResultConsumer(closeAfter); + table.scan(scan, consumer); + results = consumer.getAll(); + } else { + SimpleScanResultConsumer consumer = new SimpleScanResultConsumer(); + table.scan(scan, consumer); + results = consumer.getAll(); + } if (scan.getBatch() > 0) { results = convertFromBatchResult(results); } return results; } + private static class LimitedScanResultConsumer implements ScanResultConsumer { + + private final int limit; + + public LimitedScanResultConsumer(int limit) { + this.limit = limit; + } + + private final List results = new ArrayList<>(); + + private Throwable error; + + private boolean finished = false; + + @Override + public synchronized boolean onNext(Result result) { + results.add(result); + return results.size() < limit; + } + + @Override + public synchronized void onError(Throwable error) { + this.error = error; + finished = true; + notifyAll(); + } + + @Override + public synchronized void onComplete() { + finished = true; + notifyAll(); + } + + public synchronized List getAll() throws Exception { + while (!finished) { + wait(); + } + if (error != null) { + Throwables.propagateIfPossible(error, Exception.class); + throw new Exception(error); + } + return results; + } + } + } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java index d9a53952ab8c..96c2d40138ca 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanAll.java @@ -60,11 +60,16 @@ protected Scan createScan() { } @Override - protected List doScan(Scan scan) throws Exception { + protected List doScan(Scan scan, int closeAfter) throws Exception { List results = getTable.get().scanAll(scan).get(); if (scan.getBatch() > 0) { results = convertFromBatchResult(results); } + // we can't really close the scan early for scanAll, but to keep the assertions + // simple in AbstractTestAsyncTableScan we'll just sublist here instead. + if (closeAfter > 0 && closeAfter < results.size()) { + results = results.subList(0, closeAfter); + } return results; } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanner.java index f832cfd759a3..2e990f763da0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScanner.java @@ -62,12 +62,21 @@ protected Scan createScan() { } @Override - protected List doScan(Scan scan) throws Exception { + protected List doScan(Scan scan, int closeAfter) throws Exception { AsyncTable table = ASYNC_CONN.getTable(TABLE_NAME, ForkJoinPool.commonPool()); List results = new ArrayList<>(); + // these tests batch settings with the sample data result in each result being + // split in two. so we must allow twice the expected results in order to reach + // our true limit. see convertFromBatchResult for details. + if (closeAfter > 0 && scan.getBatch() > 0) { + closeAfter = closeAfter * 2; + } try (ResultScanner scanner = table.getScanner(scan)) { for (Result result; (result = scanner.next()) != null;) { results.add(result); + if (closeAfter > 0 && results.size() >= closeAfter) { + break; + } } } if (scan.getBatch() > 0) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java index 78a54edd24b3..26c201e19865 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRawAsyncTableScan.java @@ -55,12 +55,21 @@ protected Scan createScan() { } @Override - protected List doScan(Scan scan) throws Exception { + protected List doScan(Scan scan, int closeAfter) throws Exception { BufferingScanResultConsumer scanConsumer = new BufferingScanResultConsumer(); ASYNC_CONN.getTable(TABLE_NAME).scan(scan, scanConsumer); List results = new ArrayList<>(); + // these tests batch settings with the sample data result in each result being + // split in two. so we must allow twice the expected results in order to reach + // our true limit. see convertFromBatchResult for details. + if (closeAfter > 0 && scan.getBatch() > 0) { + closeAfter = closeAfter * 2; + } for (Result result; (result = scanConsumer.take()) != null;) { results.add(result); + if (closeAfter > 0 && results.size() >= closeAfter) { + break; + } } if (scan.getBatch() > 0) { results = convertFromBatchResult(results); From 712abb657404911e48482810012d8fa5c2062c44 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Thu, 3 Mar 2022 18:02:55 -0500 Subject: [PATCH 3/7] fix tests and fix priority of openScanner call --- .../hbase/client/AsyncClientScanner.java | 1 + .../client/TestAsyncTableRpcPriority.java | 161 +++++++++++------- 2 files changed, 100 insertions(+), 62 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java index 5fd00a5f6ed2..48f004c0a29c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncClientScanner.java @@ -188,6 +188,7 @@ private void startScan(OpenScannerResponse resp) { private CompletableFuture openScanner(int replicaId) { return conn.callerFactory. single().table(tableName) .row(scan.getStartRow()).replicaId(replicaId).locateType(getLocateType(scan)) + .priority(scan.getPriority()) .rpcTimeout(rpcTimeoutNs, TimeUnit.NANOSECONDS) .operationTimeout(scanTimeoutNs, TimeUnit.NANOSECONDS).pause(pauseNs, TimeUnit.NANOSECONDS) .pauseForCQTBE(pauseForCQTBENs, TimeUnit.NANOSECONDS).maxAttempts(maxAttempts) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index 77f71d88b622..53333dfaf5dd 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -21,7 +21,10 @@ import static org.apache.hadoop.hbase.HConstants.NORMAL_QOS; import static org.apache.hadoop.hbase.HConstants.SYSTEMTABLE_QOS; import static org.apache.hadoop.hbase.NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; @@ -35,6 +38,9 @@ import java.io.IOException; import java.util.Arrays; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; @@ -92,6 +98,8 @@ public class TestAsyncTableRpcPriority { private ClientService.Interface stub; + private ExecutorService threadPool; + private AsyncConnection conn; @Rule @@ -99,34 +107,9 @@ public class TestAsyncTableRpcPriority { @Before public void setUp() throws IOException { + this.threadPool = Executors.newSingleThreadExecutor(); stub = mock(ClientService.Interface.class); - AtomicInteger scanNextCalled = new AtomicInteger(0); - doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - ScanRequest req = invocation.getArgument(1); - RpcCallback done = invocation.getArgument(2); - if (!req.hasScannerId()) { - done.run(ScanResponse.newBuilder().setScannerId(1).setTtl(800) - .setMoreResultsInRegion(true).setMoreResults(true).build()); - } else { - if (req.hasCloseScanner() && req.getCloseScanner()) { - done.run(ScanResponse.getDefaultInstance()); - } else { - Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setType(Type.Put) - .setRow(Bytes.toBytes(scanNextCalled.incrementAndGet())) - .setFamily(Bytes.toBytes("cf")).setQualifier(Bytes.toBytes("cq")) - .setValue(Bytes.toBytes("v")).build(); - Result result = Result.create(Arrays.asList(cell)); - done.run( - ScanResponse.newBuilder().setScannerId(1).setTtl(800).setMoreResultsInRegion(true) - .setMoreResults(true).addResults(ProtobufUtil.toResult(result)).build()); - } - } - return null; - } - }).when(stub).scan(any(HBaseRpcController.class), any(ScanRequest.class), any()); doAnswer(new Answer() { @Override @@ -489,69 +472,123 @@ public void testCheckAndMutateMetaTable() throws IOException { any(ClientProtos.MultiRequest.class), any()); } + private void mockScan(int scanPriority) { + int scannerId = 1; + AtomicInteger scanNextCalled = new AtomicInteger(0); + doAnswer(new Answer() { + + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + threadPool.submit(() ->{ + ScanRequest req = invocation.getArgument(1); + RpcCallback done = invocation.getArgument(2); + if (!req.hasScannerId()) { + done.run( + ScanResponse.newBuilder().setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true).setMoreResults(true).build()); + } else { + assertFalse("close scanner should not come in with scan priority " + scanPriority, + req.hasCloseScanner() && req.getCloseScanner()); + + Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setType(Type.Put).setRow(Bytes.toBytes(scanNextCalled.incrementAndGet())) + .setFamily(Bytes.toBytes("cf")).setQualifier(Bytes.toBytes("cq")).setValue(Bytes.toBytes("v")).build(); + Result result = Result.create(Arrays.asList(cell)); + done.run( + ScanResponse.newBuilder().setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true).setMoreResults(true).addResults(ProtobufUtil.toResult(result)).build()); + } + }); + return null; + } + }).when(stub).scan(assertPriority(scanPriority), any(ScanRequest.class), any()); + + doAnswer(new Answer() { + + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + threadPool.submit(() ->{ + ScanRequest req = invocation.getArgument(1); + RpcCallback done = invocation.getArgument(2); + assertTrue("close request should have scannerId", req.hasScannerId()); + assertEquals("close request's scannerId should match", scannerId, req.getScannerId()); + assertTrue("close request should have closerScanner set", req.hasCloseScanner() && req.getCloseScanner()); + + done.run(ScanResponse.getDefaultInstance()); + }); + return null; + } + }).when(stub).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + } + @Test public void testScan() throws IOException, InterruptedException { + mockScan(19); try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setPriority(19).setLimit(10))) { - for (Result result : scanner) { - assertNotNull(result); - Thread.sleep(1000); - } + .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setPriority(19))) { + assertNotNull(scanner.next()); + Thread.sleep(1000); } - Thread.sleep(1000); + // ensures the close thread has time to finish before asserting + threadPool.shutdown(); + threadPool.awaitTermination(5, TimeUnit.SECONDS); + + // just verify that the calls happened. verification of priority occurred in the mocking // open, next, then several renew lease - verify(stub, atLeast(3)).scan(assertPriority(19), any(ScanRequest.class), any()); - // close should use high qos - verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); + verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); } @Test public void testScanNormalTable() throws IOException, InterruptedException { + mockScan(NORMAL_QOS); try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setLimit(10))) { - for (Result result : scanner) { - assertNotNull(result); - Thread.sleep(1000); - } + .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { + assertNotNull(scanner.next()); + Thread.sleep(1000); } - Thread.sleep(1000); + // ensures the close thread has time to finish before asserting + threadPool.shutdown(); + threadPool.awaitTermination(5, TimeUnit.SECONDS); + + // just verify that the calls happened. verification of priority occurred in the mocking // open, next, then several renew lease - verify(stub, atLeast(3)).scan(assertPriority(NORMAL_QOS), any(ScanRequest.class), any()); - // close should use high qos - verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); + verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); } @Test public void testScanSystemTable() throws IOException, InterruptedException { + mockScan(SYSTEMTABLE_QOS); try (ResultScanner scanner = conn.getTable(TableName.valueOf(SYSTEM_NAMESPACE_NAME_STR, name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setLimit(10))) { - for (Result result : scanner) { - assertNotNull(result); - Thread.sleep(1000); - } + .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { + assertNotNull(scanner.next()); + Thread.sleep(1000); } - Thread.sleep(1000); + // ensures the close thread has time to finish before asserting + threadPool.shutdown(); + threadPool.awaitTermination(5, TimeUnit.SECONDS); + + // just verify that the calls happened. verification of priority occurred in the mocking // open, next, then several renew lease - verify(stub, atLeast(3)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); - // close should use high qos - verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); + verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); } @Test public void testScanMetaTable() throws IOException, InterruptedException { + mockScan(SYSTEMTABLE_QOS); try (ResultScanner scanner = conn.getTable(TableName.META_TABLE_NAME) .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - for (Result result : scanner) { - assertNotNull(result); - Thread.sleep(1000); - } + assertNotNull(scanner.next()); + Thread.sleep(1000); } - Thread.sleep(1000); - // open, next, several renew lease, and then close - verify(stub, atLeast(3)).scan(assertPriority(SYSTEMTABLE_QOS), any(ScanRequest.class), any()); - // close should use high qos - verify(stub, times(1)).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + // ensures the close thread has time to finish before asserting + threadPool.shutdown(); + threadPool.awaitTermination(5, TimeUnit.SECONDS); + + // just verify that the calls happened. verification of priority occurred in the mocking + // open, next, then several renew lease + verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); + verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); } @Test From 7469dbd5f8c5409c2abb999dfc4c31a849f94399 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Fri, 4 Mar 2022 11:49:10 -0500 Subject: [PATCH 4/7] clean up tests --- .../client/TestAsyncTableRpcPriority.java | 88 +++++++------------ .../client/AbstractTestAsyncTableScan.java | 3 - 2 files changed, 34 insertions(+), 57 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index 53333dfaf5dd..b4fe03d5cc83 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -37,6 +37,7 @@ import java.io.IOException; import java.util.Arrays; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -472,8 +473,9 @@ public void testCheckAndMutateMetaTable() throws IOException { any(ClientProtos.MultiRequest.class), any()); } - private void mockScan(int scanPriority) { + private CompletableFuture mockScanReturnRenewFuture(int scanPriority) { int scannerId = 1; + CompletableFuture future = new CompletableFuture<>(); AtomicInteger scanNextCalled = new AtomicInteger(0); doAnswer(new Answer() { @@ -486,6 +488,10 @@ public Void answer(InvocationOnMock invocation) throws Throwable { done.run( ScanResponse.newBuilder().setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true).setMoreResults(true).build()); } else { + if (req.hasRenew() && req.getRenew()) { + future.complete(null); + } + assertFalse("close scanner should not come in with scan priority " + scanPriority, req.hasCloseScanner() && req.getCloseScanner()); @@ -516,78 +522,52 @@ public Void answer(InvocationOnMock invocation) throws Throwable { return null; } }).when(stub).scan(assertPriority(HIGH_QOS), assertScannerCloseRequest(), any()); + return future; } @Test - public void testScan() throws IOException, InterruptedException { - mockScan(19); - try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1).setPriority(19))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); - } - // ensures the close thread has time to finish before asserting - threadPool.shutdown(); - threadPool.awaitTermination(5, TimeUnit.SECONDS); - - // just verify that the calls happened. verification of priority occurred in the mocking - // open, next, then several renew lease - verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); - verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); + public void testScan() throws Exception { + CompletableFuture renewFuture = mockScanReturnRenewFuture(19); + testForTable(TableName.valueOf(name.getMethodName()), renewFuture, Optional.of(19)); } @Test - public void testScanNormalTable() throws IOException, InterruptedException { - mockScan(NORMAL_QOS); - try (ResultScanner scanner = conn.getTable(TableName.valueOf(name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); - } - // ensures the close thread has time to finish before asserting - threadPool.shutdown(); - threadPool.awaitTermination(5, TimeUnit.SECONDS); - - // just verify that the calls happened. verification of priority occurred in the mocking - // open, next, then several renew lease - verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); - verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); + public void testScanNormalTable() throws Exception { + CompletableFuture renewFuture = mockScanReturnRenewFuture(NORMAL_QOS); + testForTable(TableName.valueOf(name.getMethodName()), renewFuture, Optional.of(NORMAL_QOS)); } @Test - public void testScanSystemTable() throws IOException, InterruptedException { - mockScan(SYSTEMTABLE_QOS); - try (ResultScanner scanner = - conn.getTable(TableName.valueOf(SYSTEM_NAMESPACE_NAME_STR, name.getMethodName())) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { - assertNotNull(scanner.next()); - Thread.sleep(1000); - } - // ensures the close thread has time to finish before asserting - threadPool.shutdown(); - threadPool.awaitTermination(5, TimeUnit.SECONDS); - - // just verify that the calls happened. verification of priority occurred in the mocking - // open, next, then several renew lease - verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); - verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); + public void testScanSystemTable() throws Exception { + CompletableFuture renewFuture = mockScanReturnRenewFuture(SYSTEMTABLE_QOS); + testForTable(TableName.valueOf(SYSTEM_NAMESPACE_NAME_STR, name.getMethodName()), + renewFuture, Optional.empty()); } @Test - public void testScanMetaTable() throws IOException, InterruptedException { - mockScan(SYSTEMTABLE_QOS); - try (ResultScanner scanner = conn.getTable(TableName.META_TABLE_NAME) - .getScanner(new Scan().setCaching(1).setMaxResultSize(1))) { + public void testScanMetaTable() throws Exception { + CompletableFuture renewFuture = mockScanReturnRenewFuture(SYSTEMTABLE_QOS); + testForTable(TableName.META_TABLE_NAME, renewFuture, Optional.empty()); + } + + private void testForTable(TableName tableName, CompletableFuture renewFuture, Optional priority) throws Exception { + Scan scan = new Scan().setCaching(1).setMaxResultSize(1); + priority.ifPresent(scan::setPriority); + + try (ResultScanner scanner = conn.getTable(tableName).getScanner(scan)) { assertNotNull(scanner.next()); - Thread.sleep(1000); + // wait for at least one renew to come in before closing + renewFuture.join(); } + // ensures the close thread has time to finish before asserting threadPool.shutdown(); threadPool.awaitTermination(5, TimeUnit.SECONDS); // just verify that the calls happened. verification of priority occurred in the mocking - // open, next, then several renew lease - verify(stub, atLeast(3)).scan(any(), any(ScanRequest.class), any()); + // open, next, then one or more lease renewals, then close + verify(stub, atLeast(4)).scan(any(), any(ScanRequest.class), any()); + // additionally, explicitly check for a close request verify(stub, times(1)).scan(any(), assertScannerCloseRequest(), any()); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java index 58aa602591ea..14456eca1b13 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java @@ -243,9 +243,6 @@ private void testReversedScan(int start, boolean startInclusive, int stop, boole int count = actualStart - actualStop; if (limit > 0) { count = Math.min(count, limit); - } - if (scan.getBatch() > 0) { - } assertEquals(count, results.size()); IntStream.range(0, count).forEach(i -> assertResultEquals(results.get(i), actualStart - i)); From 5e1dc27db3b87bfd0ef6e36c5e571a1764cabafc Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Fri, 4 Mar 2022 15:41:22 -0500 Subject: [PATCH 5/7] checkstyle --- .../client/TestAsyncTableRpcPriority.java | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index b4fe03d5cc83..9e2f9bf12f26 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -29,11 +29,7 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.*; import java.io.IOException; import java.util.Arrays; @@ -43,6 +39,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell.Type; @@ -55,21 +52,6 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.security.UserProvider; -import org.apache.hadoop.hbase.testclassification.ClientTests; -import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.util.Bytes; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.mockito.ArgumentMatcher; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; - import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService; @@ -84,6 +66,19 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse; +import org.apache.hadoop.hbase.testclassification.ClientTests; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.mockito.ArgumentMatcher; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; /** * Confirm that we will set the priority in {@link HBaseRpcController} for several table operations. @@ -479,27 +474,35 @@ private CompletableFuture mockScanReturnRenewFuture(int scanPriority) { AtomicInteger scanNextCalled = new AtomicInteger(0); doAnswer(new Answer() { + @SuppressWarnings("FutureReturnValueIgnored") @Override public Void answer(InvocationOnMock invocation) throws Throwable { - threadPool.submit(() ->{ + threadPool.submit(() -> { ScanRequest req = invocation.getArgument(1); RpcCallback done = invocation.getArgument(2); if (!req.hasScannerId()) { - done.run( - ScanResponse.newBuilder().setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true).setMoreResults(true).build()); + done.run(ScanResponse.newBuilder() + .setScannerId(scannerId).setTtl(800) + .setMoreResultsInRegion(true).setMoreResults(true) + .build()); } else { if (req.hasRenew() && req.getRenew()) { future.complete(null); } assertFalse("close scanner should not come in with scan priority " + scanPriority, - req.hasCloseScanner() && req.getCloseScanner()); + req.hasCloseScanner() && req.getCloseScanner()); - Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setType(Type.Put).setRow(Bytes.toBytes(scanNextCalled.incrementAndGet())) - .setFamily(Bytes.toBytes("cf")).setQualifier(Bytes.toBytes("cq")).setValue(Bytes.toBytes("v")).build(); - Result result = Result.create(Arrays.asList(cell)); - done.run( - ScanResponse.newBuilder().setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true).setMoreResults(true).addResults(ProtobufUtil.toResult(result)).build()); + Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) + .setType(Type.Put).setRow(Bytes.toBytes(scanNextCalled.incrementAndGet())) + .setFamily(Bytes.toBytes("cf")).setQualifier(Bytes.toBytes("cq")) + .setValue(Bytes.toBytes("v")).build(); + Result result = Result.create(Arrays.asList(cell)); + done.run( + ScanResponse.newBuilder() + .setScannerId(scannerId).setTtl(800).setMoreResultsInRegion(true) + .setMoreResults(true).addResults(ProtobufUtil.toResult(result)) + .build()); } }); return null; @@ -508,6 +511,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable { doAnswer(new Answer() { + @SuppressWarnings("FutureReturnValueIgnored") @Override public Void answer(InvocationOnMock invocation) throws Throwable { threadPool.submit(() ->{ @@ -515,7 +519,8 @@ public Void answer(InvocationOnMock invocation) throws Throwable { RpcCallback done = invocation.getArgument(2); assertTrue("close request should have scannerId", req.hasScannerId()); assertEquals("close request's scannerId should match", scannerId, req.getScannerId()); - assertTrue("close request should have closerScanner set", req.hasCloseScanner() && req.getCloseScanner()); + assertTrue("close request should have closerScanner set", + req.hasCloseScanner() && req.getCloseScanner()); done.run(ScanResponse.getDefaultInstance()); }); @@ -550,7 +555,8 @@ public void testScanMetaTable() throws Exception { testForTable(TableName.META_TABLE_NAME, renewFuture, Optional.empty()); } - private void testForTable(TableName tableName, CompletableFuture renewFuture, Optional priority) throws Exception { + private void testForTable(TableName tableName, CompletableFuture renewFuture, + Optional priority) throws Exception { Scan scan = new Scan().setCaching(1).setMaxResultSize(1); priority.ifPresent(scan::setPriority); From f2f2008d7926fce5220f0b53fb64e635d295ffe8 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Fri, 4 Mar 2022 19:54:58 -0500 Subject: [PATCH 6/7] fix imports --- .../client/TestAsyncTableRpcPriority.java | 26 +++++++++---------- .../hbase/client/TestAsyncTableScan.java | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index 9e2f9bf12f26..bf7c8f4caad8 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -52,6 +52,19 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.security.UserProvider; +import org.apache.hadoop.hbase.testclassification.ClientTests; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.mockito.ArgumentMatcher; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService; @@ -66,19 +79,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse; -import org.apache.hadoop.hbase.testclassification.ClientTests; -import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.mockito.ArgumentMatcher; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; /** * Confirm that we will set the priority in {@link HBaseRpcController} for several table operations. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java index 04aaba1deacb..c1797f3833c3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableScan.java @@ -24,13 +24,13 @@ import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.LargeTests; -import org.apache.hbase.thirdparty.com.google.common.base.Throwables; import org.junit.ClassRule; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import org.apache.hbase.thirdparty.com.google.common.base.Throwables; @RunWith(Parameterized.class) @Category({ LargeTests.class, ClientTests.class }) From 9868c1fc92806f8f59ed3c95ddaf13b02363a0d8 Mon Sep 17 00:00:00 2001 From: Bryan Beaudreault Date: Sat, 5 Mar 2022 08:33:19 -0500 Subject: [PATCH 7/7] single import --- .../hadoop/hbase/client/TestAsyncTableRpcPriority.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java index bf7c8f4caad8..bc5ebf4e9fff 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRpcPriority.java @@ -29,7 +29,11 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import java.io.IOException; import java.util.Arrays;