From 3a1b53f2fc106a2f73bb6e428682ed659869973b Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 5 Mar 2013 04:39:43 +0000 Subject: [PATCH] HBASE-7966 ACL tests fail on trunk (flaky) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1452662 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/HBaseTestingUtility.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 0d58d2ef99c..c47f4a1a99e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -1871,11 +1871,25 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { return HFileSystem.get(conf); } + /** + * Wait until all regions in a table have been assigned. Waits default timeout before giving up + * (30 seconds). + * @param table Table to wait on. + * @throws InterruptedException + * @throws IOException + */ public void waitTableAvailable(byte[] table) throws InterruptedException, IOException { waitTableAvailable(table, 30000); } + /** + * Wait until all regions in a table have been assigned + * @param table Table to wait on. + * @param timeoutMillis Timeout. + * @throws InterruptedException + * @throws IOException + */ public void waitTableAvailable(byte[] table, long timeoutMillis) throws InterruptedException, IOException { long startWait = System.currentTimeMillis(); @@ -1887,19 +1901,38 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } } + /** + * Waits for a table to be 'enabled'. Enabled means that table is set as 'enabled' and the + * regions have been all assigned. Will timeout after default period (30 seconds) + * @see #waitTableAvailable(byte[]) + * @param table Table to wait on. + * @param table + * @throws InterruptedException + * @throws IOException + */ public void waitTableEnabled(byte[] table) throws InterruptedException, IOException { waitTableEnabled(table, 30000); } + /** + * Waits for a table to be 'enabled'. Enabled means that table is set as 'enabled' and the + * regions have been all assigned. + * @see #waitTableAvailable(byte[]) + * @param table Table to wait on. + * @param timeoutMillis Time to wait on it being marked enabled. + * @throws InterruptedException + * @throws IOException + */ public void waitTableEnabled(byte[] table, long timeoutMillis) throws InterruptedException, IOException { long startWait = System.currentTimeMillis(); - while (!getHBaseAdmin().isTableAvailable(table) && - !getHBaseAdmin().isTableEnabled(table)) { + waitTableAvailable(table, timeoutMillis); + long remainder = System.currentTimeMillis() - startWait; + while (!getHBaseAdmin().isTableEnabled(table)) { assertTrue("Timed out waiting for table to become available and enabled " + Bytes.toStringBinary(table), - System.currentTimeMillis() - startWait < timeoutMillis); + System.currentTimeMillis() - remainder < timeoutMillis); Thread.sleep(200); } }