You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2014/10/18 15:40:51 UTC

git commit: HBASE-12229 NullPointerException in SnapshotTestingUtils (Dima Spivak)

Repository: hbase
Updated Branches:
  refs/heads/0.98 ad2d41d7a -> d9a730e66


HBASE-12229 NullPointerException in SnapshotTestingUtils (Dima Spivak)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d9a730e6
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d9a730e6
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d9a730e6

Branch: refs/heads/0.98
Commit: d9a730e666e06991afaa0c5c13761793db5d93b8
Parents: ad2d41d
Author: Ted Yu <te...@apache.org>
Authored: Sat Oct 18 13:40:37 2014 +0000
Committer: Ted Yu <te...@apache.org>
Committed: Sat Oct 18 13:40:37 2014 +0000

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/HBaseTestingUtility.java | 15 +++++++++++++++
 .../hadoop/hbase/snapshot/SnapshotTestingUtils.java  | 15 +++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d9a730e6/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
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 16fd631..cc173f1 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
@@ -1207,6 +1207,21 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
 
   /**
    * Create a table.
+   * @param htd
+   * @param splitRows
+   * @return An HTable instance for the created table.
+   * @throws IOException
+   */
+  public HTable createTable(HTableDescriptor htd, byte[][] splitRows)
+      throws IOException {
+    getHBaseAdmin().createTable(htd, splitRows);
+    // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are assigned
+    waitUntilAllRegionsAssigned(htd.getTableName());
+    return new HTable(getConfiguration(), htd.getTableName());
+  }
+
+  /**
+   * Create a table.
    * @param tableName
    * @param families
    * @param c Configuration to use

http://git-wip-us.apache.org/repos/asf/hbase/blob/d9a730e6/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
index f3a399e..072e044 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/SnapshotTestingUtils.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.TableNotEnabledException;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
@@ -630,13 +631,20 @@ public class SnapshotTestingUtils {
     for (HRegion region : onlineRegions) {
       region.waitForFlushesAndCompactions();
     }
-    util.getHBaseAdmin().isTableAvailable(tableName);
+    // Wait up to 60 seconds for a table to be available.
+    final HBaseAdmin hBaseAdmin = util.getHBaseAdmin();
+    util.waitFor(60000, new Waiter.Predicate<IOException>() {
+      @Override
+      public boolean evaluate() throws IOException {
+        return hBaseAdmin.isTableAvailable(tableName);
+      }
+    });
   }
 
   public static void createTable(final HBaseTestingUtility util, final TableName tableName,
       final byte[]... families) throws IOException, InterruptedException {
     HTableDescriptor htd = new HTableDescriptor(tableName);
-    for (byte[] family: families) {
+    for (byte[] family : families) {
       HColumnDescriptor hcd = new HColumnDescriptor(family);
       htd.addFamily(hcd);
     }
@@ -644,8 +652,7 @@ public class SnapshotTestingUtils {
     for (int i = 0; i < splitKeys.length; ++i) {
       splitKeys[i] = new byte[] { KEYS[i+1] };
     }
-    util.getHBaseAdmin().createTable(htd, splitKeys);
-    waitForTableToBeOnline(util, tableName);
+    util.createTable(htd, splitKeys);
     assertEquals(KEYS.length-1, util.getHBaseAdmin().getTableRegions(tableName).size());
   }