From 5a36e4032a891800812b009554e869fea0db30b9 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 14 Dec 2010 03:39:55 +0000 Subject: [PATCH] HBASE-3352 enabling a non-existent table from shell prints no error git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1048922 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/main/ruby/hbase/admin.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6cce39636a1..af2d00c877c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -766,6 +766,7 @@ Release 0.90.0 - Unreleased HBASE-3347 Can't truncate/disable table that has rows in .META. that have empty info:regioninfo column HBASE-3321 Replication.join shouldn't clear the logs znode + HBASE-3352 enabling a non-existent table from shell prints no error IMPROVEMENTS diff --git a/src/main/ruby/hbase/admin.rb b/src/main/ruby/hbase/admin.rb index 8933309d98b..0f480c06230 100644 --- a/src/main/ruby/hbase/admin.rb +++ b/src/main/ruby/hbase/admin.rb @@ -92,6 +92,7 @@ module Hbase #---------------------------------------------------------------------------------------------- # Enables a table def enable(table_name) + tableExists(table_name) return if enabled?(table_name) @admin.enableTable(table_name) end @@ -99,10 +100,17 @@ module Hbase #---------------------------------------------------------------------------------------------- # Disables a table def disable(table_name) + tableExists(table_name) return if disabled?(table_name) @admin.disableTable(table_name) end + #--------------------------------------------------------------------------------------------- + # Throw exception if table doesn't exist + def tableExists(table_name) + raise ArgumentError, "Table #{table_name} does not exist.'" unless exists?(table_name) + end + #---------------------------------------------------------------------------------------------- # Is table disabled? def disabled?(table_name) @@ -112,7 +120,7 @@ module Hbase #---------------------------------------------------------------------------------------------- # Drops a table def drop(table_name) - raise ArgumentError, "Table #{table_name} does not exist.'" unless exists?(table_name) + tableExists(table_name) raise ArgumentError, "Table #{table_name} is enabled. Disable it first.'" if enabled?(table_name) @admin.deleteTable(table_name)