hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1594430 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java test/java/org/apache/hadoop/hbase/client/TestAdmin.java
Date Wed, 14 May 2014 00:33:35 GMT
Author: liyin
Date: Wed May 14 00:33:35 2014
New Revision: 1594430

URL: http://svn.apache.org/r1594430
Log:
[HBASE-11138][0.89-fb] Check for an empty split key before creating a table

Author: gauravm

Summary: HBaseAdmin#checkSplitKeys() doesn't check for empty split keys, which can cause multiple
regions with the same start key (i.e., ""). This diff fixes that.

Test Plan: Added a unit test

Reviewers: rshroff, manukranthk, aaiyer, daviddeng

Reviewed By: daviddeng

CC: hbase-eng@, daviddeng

Differential Revision: https://phabricator.fb.com/D1316709

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1594430&r1=1594429&r2=1594430&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Wed
May 14 00:33:35 2014
@@ -333,6 +333,11 @@ public class HBaseAdmin {
       // Verify there are no duplicate split keys
       byte[] lastKey = null;
       for (byte[] splitKey : splitKeys) {
+        if (Bytes.equals(splitKey, HConstants.EMPTY_BYTE_ARRAY)) {
+          throw new IllegalArgumentException(
+            "Split keys cannot be empty"
+          );
+        }
         if (lastKey != null && Bytes.equals(splitKey, lastKey)) {
           throw new IllegalArgumentException(
               "All split keys must be unique, found duplicate");

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1594430&r1=1594429&r2=1594430&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Wed
May 14 00:33:35 2014
@@ -695,5 +695,17 @@ public class TestAdmin {
 
   }
 
+  @Test(expected = IllegalArgumentException.class)
+  public void testSplitKeysDoesNotHaveEmptyString() {
+    // This test will check if the split keys provided during createTable,
+    // does not have an empty string. Otherwise, there will be multiple regions
+    // with start key as "".
+    byte[][] splitKeys = {
+      HConstants.EMPTY_BYTE_ARRAY,
+      Bytes.toBytes("mmm")
+    };
+    admin.checkSplitKeys(splitKeys);
+  }
+
 }
 



Mime
View raw message