hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1483657 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java test/java/org/apache/hadoop/hbase/client/TestAdmin.java
Date Fri, 17 May 2013 05:50:18 GMT
Author: larsh
Date: Fri May 17 05:50:18 2013
New Revision: 1483657

URL: http://svn.apache.org/r1483657
Log:
HBASE-8538 HBaseAdmin#isTableEnabled() should check table existence before checking zk state.
(rajeshbabu)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1483657&r1=1483656&r2=1483657&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Fri May
17 05:50:18 2013
@@ -934,6 +934,9 @@ public class HBaseAdmin implements Abort
     if (!HTableDescriptor.isMetaTable(tableName)) {
       HTableDescriptor.isLegalTableName(tableName);
     }
+    if(!tableExists(tableName)){
+      throw new TableNotFoundException(Bytes.toString(tableName));
+    }
     return connection.isTableEnabled(tableName);
   }
 

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java?rev=1483657&r1=1483656&r2=1483657&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTableReadOnly.java
Fri May 17 05:50:18 2013
@@ -66,6 +66,8 @@ public class ZKTableReadOnly {
   public static boolean isEnabledTable(final ZooKeeperWatcher zkw,
       final String tableName) throws KeeperException {
     TableState state = getTableState(zkw, tableName);
+    // If a table is ENABLED then we are removing table state znode in 0.92
+    // but in 0.94 we keep it in ENABLED state.
     return state == null || state == TableState.ENABLED;
   }
 

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1483657&r1=1483656&r2=1483657&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Fri May
17 05:50:18 2013
@@ -256,6 +256,15 @@ public class TestAdmin {
   }
 
   @Test
+  public void testIsEnabledOnUnknownTable() throws Exception {
+    try {
+      admin.isTableEnabled(Bytes.toBytes("unkownTable"));
+      fail("Test should fail if isTableEnabled called on unknown table.");
+    } catch (IOException e) {
+    }
+  }
+  
+  @Test
   public void testDisableAndEnableTables() throws IOException {
     final byte [] row = Bytes.toBytes("row");
     final byte [] qualifier = Bytes.toBytes("qualifier");



Mime
View raw message