Skip to content

Commit fc3fb26

Browse files
rmdmattinglybbeaudreault
authored andcommitted
HubSpot Backport: Addendum HBASE-28349 Count atomic operations against read quotas (apache#5670)
Signed-off-by: Bryan Beaudreault <[email protected]>
1 parent a5c2b4f commit fc3fb26

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.hadoop.hbase.client.CheckAndMutate;
3131
import org.apache.hadoop.hbase.client.Increment;
3232
import org.apache.hadoop.hbase.client.Put;
33+
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
3334
import org.apache.hadoop.hbase.client.RowMutations;
3435
import org.apache.hadoop.hbase.client.Table;
3536
import 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

Comments
 (0)