You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/10/18 04:51:08 UTC
git commit: HBASE-12229 NullPointerException in SnapshotTestingUtils
Repository: hbase
Updated Branches:
refs/heads/master 349a56ae2 -> 7e995b649
HBASE-12229 NullPointerException in SnapshotTestingUtils
* Implemented the waitUntilAllRegionsOnline in HBaseTestingUtility#createTable
* Add waitFor around #isTableAvailable call that previously didn't do anything
* Remove unused byte[] hex
Signed-off-by: stack <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7e995b64
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7e995b64
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7e995b64
Branch: refs/heads/master
Commit: 7e995b6496a44c057337535363aee778f52318b9
Parents: 349a56a
Author: Dima Spivak <ds...@cloudera.com>
Authored: Wed Oct 15 22:02:54 2014 -0700
Committer: stack <st...@apache.org>
Committed: Fri Oct 17 22:50:10 2014 -0400
----------------------------------------------------------------------
.../apache/hadoop/hbase/HBaseTestingUtility.java | 15 +++++++++++++++
.../hbase/snapshot/SnapshotTestingUtils.java | 17 ++++++++++++-----
2 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/7e995b64/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 bbd9dbe..450e805 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
@@ -1208,6 +1208,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/7e995b64/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 6a9c0dc..f0070d8 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
@@ -45,8 +45,10 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotEnabledException;
+import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
@@ -633,27 +635,32 @@ 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,
int regionReplication, final byte[]... families) throws IOException, InterruptedException {
HTableDescriptor htd = new HTableDescriptor(tableName);
htd.setRegionReplication(regionReplication);
- for (byte[] family: families) {
+ for (byte[] family : families) {
HColumnDescriptor hcd = new HColumnDescriptor(family);
htd.addFamily(hcd);
}
byte[][] splitKeys = getSplitKeys();
- util.getHBaseAdmin().createTable(htd, splitKeys);
- waitForTableToBeOnline(util, tableName);
+ util.createTable(htd, splitKeys);
assertEquals((splitKeys.length + 1) * regionReplication,
util.getHBaseAdmin().getTableRegions(tableName).size());
}
public static byte[][] getSplitKeys() {
byte[][] splitKeys = new byte[KEYS.length-2][];
- byte[] hex = Bytes.toBytes("123456789abcde");
for (int i = 0; i < splitKeys.length; ++i) {
splitKeys[i] = new byte[] { KEYS[i+1] };
}