3030import org .apache .hadoop .hbase .client .CheckAndMutate ;
3131import org .apache .hadoop .hbase .client .Increment ;
3232import org .apache .hadoop .hbase .client .Put ;
33+ import org .apache .hadoop .hbase .client .RetriesExhaustedWithDetailsException ;
3334import org .apache .hadoop .hbase .client .RowMutations ;
3435import org .apache .hadoop .hbase .client .Table ;
3536import org .apache .hadoop .hbase .security .User ;
@@ -66,6 +67,9 @@ public static void tearDown() throws Exception {
6667
6768 @ BeforeClass
6869 public static void setUpBeforeClass () throws Exception {
70+ TEST_UTIL .getConfiguration ().setInt ("hbase.client.pause" , 1 );
71+ TEST_UTIL .getConfiguration ().setInt (HConstants .HBASE_CLIENT_RETRIES_NUMBER , 1 );
72+ TEST_UTIL .getConfiguration ().setInt (HConstants .HBASE_CLIENT_PAUSE , 1 );
6973 TEST_UTIL .getConfiguration ().setBoolean (QuotaUtil .QUOTA_CONF_KEY , true );
7074 TEST_UTIL .getConfiguration ().setInt (QuotaCache .REFRESH_CONF_KEY , 1000 );
7175 TEST_UTIL .startMiniCluster (1 );
@@ -181,7 +185,7 @@ public void testAtomicBatchCountedAgainstReadCapacity() throws Exception {
181185 incs .add (inc );
182186
183187 testThrottle (table -> {
184- Object [] results = new Object [] {} ;
188+ Object [] results = new Object [incs . size ()] ;
185189 table .batch (incs , results );
186190 return results ;
187191 });
@@ -206,25 +210,29 @@ private void testThrottle(ThrowingFunction<Table, ?> request) throws Exception {
206210 try (Table table = getTable ()) {
207211 // we have a read quota configured, so this should fail
208212 TEST_UTIL .waitFor (60_000 , () -> {
213+ boolean success ;
214+ Exception ex ;
209215 try {
210216 request .run (table );
211217 return false ;
218+ } catch (RetriesExhaustedWithDetailsException e ) {
219+ success = e .getCauses ().stream ().allMatch (t -> t instanceof RpcThrottlingException );
220+ ex = e ;
212221 } catch (Exception e ) {
213- boolean success = e .getCause () instanceof RpcThrottlingException ;
214- if (! success ) {
215- LOG . error ( "Unexpected exception" , e );
216- }
217- return success ;
222+ success = e .getCause () instanceof RpcThrottlingException ;
223+ ex = e ;
224+ }
225+ if (! success ) {
226+ LOG . error ( "Unexpected exception" , ex ) ;
218227 }
228+ return success ;
219229 });
220230 } finally {
221231 cleanupQuota ();
222232 }
223233 }
224234
225235 private Table getTable () throws IOException {
226- TEST_UTIL .getConfiguration ().setInt ("hbase.client.pause" , 100 );
227- TEST_UTIL .getConfiguration ().setInt (HConstants .HBASE_CLIENT_RETRIES_NUMBER , 1 );
228236 return TEST_UTIL .getConnection ().getTableBuilder (TABLE_NAME , null ).setOperationTimeout (250 )
229237 .build ();
230238 }
0 commit comments