hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hbase git commit: HBASE-13812 Deleting of last Column Family of a table should not be allowed
Date Sat, 30 May 2015 23:50:17 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.1 6c0a4b425 -> 5f1ad5ea1


HBASE-13812 Deleting of last Column Family of a table should not be allowed

Conflicts:
	hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java


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

Branch: refs/heads/branch-1.1
Commit: 5f1ad5ea1cc584489799e0f789362a9ab3a106e9
Parents: 6c0a4b4
Author: Enis Soztutar <enis@apache.org>
Authored: Sat May 30 16:30:48 2015 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Sat May 30 16:43:24 2015 -0700

----------------------------------------------------------------------
 .../procedure/DeleteColumnFamilyProcedure.java  |  5 +++
 .../apache/hadoop/hbase/client/TestAdmin1.java  | 35 ++++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5f1ad5ea/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
index 316f225..3341907 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteColumnFamilyProcedure.java
@@ -283,6 +283,11 @@ public class DeleteColumnFamilyProcedure
       throw new InvalidFamilyOperationException("Family '" + getColumnFamilyName()
           + "' does not exist, so it cannot be deleted");
     }
+
+    if (unmodifiedHTableDescriptor.getColumnFamilies().length == 1) {
+      throw new InvalidFamilyOperationException("Family '" + getColumnFamilyName()
+        + "' is the only column family in the table, so it cannot be deleted");
+    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/5f1ad5ea/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
index 400d929..b1ff380 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
@@ -1296,11 +1296,11 @@ public class TestAdmin1 {
 
   @Test (timeout=300000)
   public void testEnableDisableAddColumnDeleteColumn() throws Exception {
-    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
-    TableName tableName = TableName.valueOf("testMasterAdmin");
+	ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
+    TableName tableName = TableName.valueOf("testEnableDisableAddColumnDeleteColumn");
     TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
     while (!ZKTableStateClientSideReader.isEnabledTable(zkw,
-      TableName.valueOf("testMasterAdmin"))) {
+      TableName.valueOf("testEnableDisableAddColumnDeleteColumn"))) {
       Thread.sleep(10);
     }
     this.admin.disableTable(tableName);
@@ -1320,4 +1320,33 @@ public class TestAdmin1 {
     this.admin.disableTable(tableName);
     this.admin.deleteTable(tableName);
   }
+
+  @Test (timeout=300000)
+  public void testDeleteLastColumnFamily() throws Exception {
+    TableName tableName = TableName.valueOf("testDeleteLastColumnFamily");
+    TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
+    while (!this.admin.isTableEnabled(TableName.valueOf("testDeleteLastColumnFamily"))) {
+      Thread.sleep(10);
+    }
+
+    // test for enabled table
+    try {
+      this.admin.deleteColumn(tableName, HConstants.CATALOG_FAMILY);
+      fail("Should have failed to delete the only column family of a table");
+    } catch (InvalidFamilyOperationException ex) {
+      // expected
+    }
+
+    // test for disabled table
+    this.admin.disableTable(tableName);
+
+    try {
+      this.admin.deleteColumn(tableName, HConstants.CATALOG_FAMILY);
+      fail("Should have failed to delete the only column family of a table");
+    } catch (InvalidFamilyOperationException ex) {
+      // expected
+    }
+
+    this.admin.deleteTable(tableName);
+  }
 }


Mime
View raw message