From bf5cd8abacd7bda144de7e870f3948837c99f2fa Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Thu, 7 Jun 2012 17:25:22 +0000 Subject: [PATCH] HBASE-6146 Disabling of Catalog tables should not be allowed (Anoop) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1347719 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/client/HBaseAdmin.java | 2 ++ .../org/apache/hadoop/hbase/client/TestAdmin.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index bdfd9cab835..90d35bf6f85 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -725,6 +725,7 @@ public class HBaseAdmin implements Abortable, Closeable { */ public void enableTableAsync(final byte [] tableName) throws IOException { + HTableDescriptor.isLegalTableName(tableName); execute(new MasterCallable() { @Override public Void call() throws ServiceException { @@ -795,6 +796,7 @@ public class HBaseAdmin implements Abortable, Closeable { * @since 0.90.0 */ public void disableTableAsync(final byte [] tableName) throws IOException { + HTableDescriptor.isLegalTableName(tableName); execute(new MasterCallable() { @Override public Void call() throws ServiceException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 8f9eb7dd5a1..24ae44e393c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -1588,6 +1588,21 @@ public class TestAdmin { " HBase was not available"); } + @Test + public void testDisableCatalogTable() throws Exception { + try { + this.admin.disableTable(".META."); + fail("Expected to throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + } + // Before the fix for HBASE-6146, the below table creation was failing as the META table + // actually getting disabled by the disableTable() call. + HTableDescriptor htd = new HTableDescriptor("testDisableCatalogTable".getBytes()); + HColumnDescriptor hcd = new HColumnDescriptor("cf1".getBytes()); + htd.addFamily(hcd); + TEST_UTIL.getHBaseAdmin().createTable(htd); + } + @org.junit.Rule public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu = new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();