hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1231555 - in /hbase/branches/0.90: ./ src/main/java/org/apache/hadoop/hbase/master/ src/main/java/org/apache/hadoop/hbase/master/handler/ src/main/java/org/apache/hadoop/hbase/zookeeper/ src/test/java/org/apache/hadoop/hbase/client/ src/te...
Date Sat, 14 Jan 2012 18:44:34 GMT
Author: ramkrishna
Date: Sat Jan 14 18:44:33 2012
New Revision: 1231555

URL: http://svn.apache.org/viewvc?rev=1231555&view=rev
Log:
HBASE-5155 ServerShutDownHandler And Disable/Delete should not happen parallely leading to
recreation of regions that were deleted (Ram)

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTable.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKTable.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Sat Jan 14 18:44:33 2012
@@ -25,7 +25,8 @@ Release 0.90.6 - Unreleased
                recovery phase after all RSs are shutdown at the same time (Ram)
    HBASE-5160  Addendum adding the removed method in AssignmentManager (Ram)
    HBASE-5192  Backport HBASE-4236 Don't lock the stream while serializing the response (Ram)
-
+   HBASE-5155  ServerShutDownHandler And Disable/Delete should not happen parallely 
+               leading to recreation of regions that were deleted (Ram)
   IMPROVEMENT
    HBASE-5102  Change the default value of the property "hbase.connection.per.config" to
false in
                 hbase-default.xml

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Sat Jan 14 18:44:33 2012
@@ -860,10 +860,14 @@ public class AssignmentManager extends Z
     String tableName = region.getTableDesc().getNameAsString();
     boolean disabled = this.zkTable.isDisabledTable(tableName);
     if (disabled || this.zkTable.isDisablingTable(tableName)) {
-      LOG.info("Table " + tableName + (disabled? " disabled;": " disabling;") +
-        " skipping assign of " + region.getRegionNameAsString());
+      LOG.info("Table " + tableName + (disabled ? " disabled;" : " disabling;")
+          + " skipping assign of " + region.getRegionNameAsString());
       offlineDisabledRegion(region);
       return;
+    } else if (!this.zkTable.isEnabledTable(tableName)) {
+      // enable the table here. the assign may be called using
+      // HMaster.assignRegion()
+      setEnabledTable(tableName);
     }
     if (this.serverManager.isClusterShutdown()) {
       LOG.info("Cluster shutdown is set; skipping assign of " +
@@ -937,9 +941,22 @@ public class AssignmentManager extends Z
     } catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
+    
     LOG.debug("Bulk assigning done for " + destination.getServerName());
   }
 
+  protected void setEnabledTable(String tableName) {
+    try {
+      this.zkTable.setEnabledTable(tableName);
+    } catch (KeeperException e) {
+      // here we can abort as it is the start up flow
+      String errorMsg = "Unable to ensure that the table " + tableName
+          + "will be" + " enabled because of a ZooKeeper issue";
+      LOG.error(errorMsg);
+      this.master.abort(errorMsg, e);
+    }
+  }
+
   /**
    * Callback handler for create unassigned znodes used during bulk assign.
    */
@@ -1384,9 +1401,23 @@ public class AssignmentManager extends Z
     // Use fixed count thread pool assigning.
     BulkAssigner ba = new StartupBulkAssigner(this.master, bulkPlan, this);
     ba.bulkAssign();
+    // As the above bulkAssign is a sync call setEnabledTable can be done here
+    ArrayList<HRegionInfo> regionsList = new ArrayList<HRegionInfo>(allRegions
+        .keySet());
+    for (HRegionInfo regionInfo : regionsList) {
+      setEnabledTable(regionInfo);
+    }
     LOG.info("Bulk assigning done");
   }
 
+  private void setEnabledTable(HRegionInfo regionInfo) {
+    String tableName = regionInfo.getTableDesc().getNameAsString();
+    boolean isTableEnabled = this.zkTable.isEnabledTable(tableName);
+    if (!isTableEnabled) {
+      setEnabledTable(tableName);
+    }
+  }
+
   /**
    * Run bulk assign on startup.  Does one RCP per regionserver passing a
    * batch of reginons using {@link SingleServerBulkAssigner}.
@@ -1577,22 +1608,28 @@ public class AssignmentManager extends Z
     Set<String> disablingTables = new HashSet<String>(1);
     // Iterate regions in META
     for (Result result : results) {
+      boolean disabled = false;
+      boolean disabling = false;
       Pair<HRegionInfo,HServerInfo> region =
         MetaReader.metaRowToRegionPairWithInfo(result);
       if (region == null) continue;
       HServerInfo regionLocation = region.getSecond();
       HRegionInfo regionInfo = region.getFirst();
-      String disablingTableName = regionInfo.getTableDesc().getNameAsString();
+      String tableName = regionInfo.getTableDesc().getNameAsString();
+      
       if (regionLocation == null) {
         // Region not being served, add to region map with no assignment
         // If this needs to be assigned out, it will also be in ZK as RIT
         // add if the table is not in disabled state
         if (false == checkIfRegionBelongsToDisabled(regionInfo)) {
           this.regions.put(regionInfo, null);
+        } else {
+          disabled = true;
         }
-        if (checkIfRegionBelongsToDisabling(regionInfo)) {
-          disablingTables.add(disablingTableName);
-        }
+        disabling = addToDisablingTables(disablingTables, regionInfo, tableName);
+        // need to enable the table if not disabled or disabling
+        // this will be used in rolling restarts
+        enableTableIfNotDisabledOrDisabling(disabled, disabling, tableName);
       } else if (!serverManager.isServerOnline(regionLocation.getServerName())) {
         // Region is located on a server that isn't online
         List<Pair<HRegionInfo,Result>> offlineRegions =
@@ -1602,16 +1639,24 @@ public class AssignmentManager extends Z
           offlineServers.put(regionLocation.getServerName(), offlineRegions);
         }
         offlineRegions.add(new Pair<HRegionInfo,Result>(regionInfo, result));
+        disabled = checkIfRegionBelongsToDisabled(regionInfo);
+        disabling = addToDisablingTables(disablingTables, regionInfo, tableName);
+        // need to enable the table if not disabled or disabling
+        // this will be used in rolling restarts
+        enableTableIfNotDisabledOrDisabling(disabled, disabling, tableName);
       } else {
         // Region is being served and on an active server
         // add only if region not in disabled table
         if (false == checkIfRegionBelongsToDisabled(regionInfo)) {
           regions.put(regionInfo, regionLocation);
           addToServers(regionLocation, regionInfo);
+        } else {
+          disabled = true;
         }
-        if (checkIfRegionBelongsToDisabling(regionInfo)) {
-          disablingTables.add(disablingTableName);
-        }
+        disabling = addToDisablingTables(disablingTables, regionInfo, tableName);
+        // need to enable the table if not disabled or disabling
+        // this will be used in rolling restarts
+        enableTableIfNotDisabledOrDisabling(disabled, disabling, tableName);
       }
     }
     // Recover the tables that were not fully moved to DISABLED state.
@@ -1632,6 +1677,22 @@ public class AssignmentManager extends Z
     }
     return offlineServers;
   }
+
+  private boolean addToDisablingTables(Set<String> disablingTables,
+      HRegionInfo regionInfo, String tableName) {
+    if (checkIfRegionBelongsToDisabling(regionInfo)) {
+      disablingTables.add(tableName);
+      return true;
+    }
+    return false;
+  }
+
+  private void enableTableIfNotDisabledOrDisabling(boolean disabled,
+      boolean disabling, String tableName) {
+    if (!disabled && !disabling && !getZKTable().isEnabledTable(tableName))
{
+      setEnabledTable(tableName);
+    }
+  }
   
   private boolean checkIfRegionBelongsToDisabled(HRegionInfo regionInfo) {
     String tableName = regionInfo.getTableDesc().getNameAsString();
@@ -2173,6 +2234,12 @@ public class AssignmentManager extends Z
     } catch (InterruptedException e) {
       throw new IOException("InterruptedException bulk assigning", e);
     }
+    // If the sync is true, we create the table node here.
+    // if the sync is false we still create the table node but cannot
+    // be sure if all the regions are assigned.
+    for (HRegionInfo regionInfo : regions) {
+      setEnabledTable(regionInfo);
+    }
     LOG.info("Bulk assigning done");
   }
 

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Sat Jan
14 18:44:33 2012
@@ -429,6 +429,9 @@ implements HMasterInterface, HMasterRegi
       this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO);
       assigned++;
     }
+    // Enable the ROOT table if on process fail over the RS containing ROOT
+    // was active.
+    enableCatalogTables(Bytes.toString(HConstants.ROOT_TABLE_NAME));
     LOG.info("-ROOT- assigned=" + assigned + ", rit=" + rit +
       ", location=" + catalogTracker.getRootLocation());
 
@@ -443,11 +446,20 @@ implements HMasterInterface, HMasterRegi
       this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
       assigned++;
     }
+    // Enable the META table if on process fail over the RS containing META
+    // was active.
+    enableCatalogTables(Bytes.toString(HConstants.META_TABLE_NAME));
     LOG.info(".META. assigned=" + assigned + ", rit=" + rit +
       ", location=" + catalogTracker.getMetaLocation());
     return assigned;
   }
 
+  private void enableCatalogTables(String catalogTableName) {
+    if (!this.assignmentManager.getZKTable().isEnabledTable(catalogTableName)) {
+      this.assignmentManager.setEnabledTable(catalogTableName);
+    }
+  }
+
   /*
    * @return This masters' address.
    * @throws UnknownHostException
@@ -781,27 +793,19 @@ implements HMasterInterface, HMasterRegi
       throw new TableExistsException(tableName);
     }
     for (HRegionInfo newRegion : newRegions) {
-      // 1. Set table enabling flag up in zk.
-      try {
-        assignmentManager.getZKTable().setEnabledTable(tableName);
-      } catch (KeeperException e) {
-        throw new IOException("Unable to ensure that the table will be" +
-          " enabled because of a ZooKeeper issue", e);
-      }
-
-      // 2. Create HRegion
+      // 1. Create HRegion
       HRegion region = HRegion.createHRegion(newRegion,
         fileSystemManager.getRootDir(), conf);
 
-      // 3. Insert into META
+      // 2. Insert into META
       MetaEditor.addRegionToMeta(catalogTracker, region.getRegionInfo());
 
-      // 4. Close the new region to flush to disk.  Close log file too.
+      // 3. Close the new region to flush to disk.  Close log file too.
       region.close();
       region.getLog().closeAndDelete();
     }
 
-    // 5. Trigger immediate assignment of the regions in round-robin fashion
+    // 4. Trigger immediate assignment of the regions in round-robin fashion
     if (newRegions.length == 1) {
       this.assignmentManager.assign(newRegions[0], true);
     } else {
@@ -809,7 +813,7 @@ implements HMasterInterface, HMasterRegi
       this.assignmentManager.bulkAssignUserRegions(newRegions, servers, sync);
     }
 
-    // 6. If sync, wait for assignment of regions
+    // 5. If sync, wait for assignment of regions
     if (sync) {
       LOG.debug("Waiting for " + newRegions.length + " region(s) to be assigned");
       for (HRegionInfo regionInfo : newRegions) {

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
Sat Jan 14 18:44:33 2012
@@ -73,6 +73,6 @@ public class DeleteTableHandler extends 
 
     // If entry for this table in zk, and up in AssignmentManager, remove it.
     // Call to undisableTable does this. TODO: Make a more formal purge table.
-    am.getZKTable().setEnabledTable(Bytes.toString(tableName));
+    am.getZKTable().setDeletedTable(Bytes.toString(tableName));
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
Sat Jan 14 18:44:33 2012
@@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
@@ -252,13 +253,29 @@ public class ServerShutdownHandler exten
   public static boolean processDeadRegion(HRegionInfo hri, Result result,
       AssignmentManager assignmentManager, CatalogTracker catalogTracker)
   throws IOException {
+	  // check if table is present in cache
+    String tableName = hri.getTableDesc().getNameAsString();
+    boolean tablePresent = assignmentManager.getZKTable().isTablePresent(
+        tableName);
+    if (!tablePresent) {
+      LOG.info("The table " + tableName
+          + " was deleted.  Hence not proceeding.");
+      return false;
+    }
     // If table is not disabled but the region is offlined,
-    boolean disabled = assignmentManager.getZKTable().isDisabledTable(
-        hri.getTableDesc().getNameAsString());
-    if (disabled) return false;
+    boolean disabled = assignmentManager.getZKTable()
+        .isDisabledTable(tableName);
+    if (disabled) {
+      LOG.info("The table " + tableName
+          + " was disabled.  Hence not proceeding.");
+      return false;
+    }
     if (hri.isOffline() && hri.isSplit()) {
-      LOG.debug("Offlined and split region " + hri.getRegionNameAsString() +
-        "; checking daughter presence");
+      LOG.debug("Offlined and split region " + hri.getRegionNameAsString()
+          + "; checking daughter presence");
+      if (MetaReader.getRegion(catalogTracker, hri.getRegionName()) == null) {
+        return false;
+      }
       fixupDaughters(result, assignmentManager, catalogTracker);
       return false;
     }

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTable.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTable.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKTable.java Sat Jan
14 18:44:33 2012
@@ -182,11 +182,29 @@ public class ZKTable {
       this.cache.put(tableName, state);
     }
   }
-
+  /**
+   * Check if the table is in DISABLED state.
+   * This check does not involve zookeeper 
+   * 
+   * @param tableName
+   * @return true if table is DISABLED
+   */
   public boolean isDisabledTable(final String tableName) {
     return isTableState(tableName, TableState.DISABLED);
   }
-
+  
+  /**
+   * check if table is present .
+   * 
+   * @param tableName
+   * @return True if the table is present
+   */
+  public boolean isTablePresent(final String tableName) {
+    synchronized (this.cache) {
+      TableState state = this.cache.get(tableName);
+      return !(state == null);
+    }
+  }
   /**
    * Go to zookeeper and see if state of table is {@link TableState#DISABLED}.
    * This method does not use cache as {@link #isDisabledTable(String)} does.
@@ -202,26 +220,45 @@ public class ZKTable {
     TableState state = getTableState(zkw, tableName);
     return isTableState(TableState.DISABLED, state);
   }
-
+  
+  /**
+   * Check if the table is in DISABLING state.
+   * This check does not involve zookeeper 
+   * 
+   * @param tableName
+   * @return true if table is DISABLING
+   */
   public boolean isDisablingTable(final String tableName) {
     return isTableState(tableName, TableState.DISABLING);
   }
-
+  
+  /**
+   * Check if the table is in ENABLING state.
+   * This check does not involve zookeeper 
+   * 
+   * @param tableName
+   * @return true if table is ENABLING
+   */
   public boolean isEnablingTable(final String tableName) {
     return isTableState(tableName, TableState.ENABLING);
   }
-
+  
+  /**
+   * Check if the table is in ENABLED state.
+   * This check does not involve zookeeper 
+   * 
+   * @param tableName
+   * @return true if table is ENABLED
+   */
   public boolean isEnabledTable(String tableName) {
-    synchronized (this.cache) {
-      // No entry in cache means enabled table.
-      return !this.cache.containsKey(tableName);
-    }
+    return isTableState(tableName, TableState.ENABLED);
   }
 
   /**
    * Go to zookeeper and see if state of table is {@link TableState#ENABLED}.
    * This method does not use cache as {@link #isEnabledTable(String)} does.
    * This method is for clients other than {@link AssignmentManager}
+   * 
    * @param zkw
    * @param tableName
    * @return True if table is enabled.
@@ -230,15 +267,22 @@ public class ZKTable {
   public static boolean isEnabledTable(final ZooKeeperWatcher zkw,
       final String tableName)
   throws KeeperException {
-    return getTableState(zkw, tableName) == null;
+    return getTableState(zkw, tableName) == TableState.ENABLED;
   }
 
+  /**
+   * Check if table is in DISABLING state or DISABLED state.
+   * This check does not involve zookeeper.
+   * 
+   * @param tableName
+   * @return true if table is in DISABLING or DISABLED state
+   */
   public boolean isDisablingOrDisabledTable(final String tableName) {
     synchronized (this.cache) {
       return isDisablingTable(tableName) || isDisabledTable(tableName);
     }
   }
-
+  
   /**
    * Go to zookeeper and see if state of table is {@link TableState#DISABLING}
    * of {@link TableState#DISABLED}.
@@ -256,13 +300,26 @@ public class ZKTable {
     return isTableState(TableState.DISABLING, state) ||
       isTableState(TableState.DISABLED, state);
   }
-
+  
+  /**
+   * Check if the table is in ENABLED or DISABLING state.
+   * This check does not involve zookeeper
+   * @param tableName
+   * @return true if the table is in ENABLED or DISABLING state
+   */
   public boolean isEnabledOrDisablingTable(final String tableName) {
     synchronized (this.cache) {
       return isEnabledTable(tableName) || isDisablingTable(tableName);
     }
   }
-
+  
+  /**
+   * Check if the table is in DISABLED or ENABLING state.
+   * This check does not involve zookeeper
+   * 
+   * @param tableName
+   * @return true if the table is in DISABLED or ENABLING state
+   */
   public boolean isDisabledOrEnablingTable(final String tableName) {
     synchronized (this.cache) {
       return isDisabledTable(tableName) || isEnablingTable(tableName);
@@ -275,6 +332,7 @@ public class ZKTable {
       return isTableState(currentState, state);
     }
   }
+  
 
   private static boolean isTableState(final TableState expectedState,
       final TableState currentState) {
@@ -282,23 +340,32 @@ public class ZKTable {
   }
 
   /**
-   * Enables the table in zookeeper.  Fails silently if the
+   * Deletes the table in zookeeper.  Fails silently if the
    * table is not currently disabled in zookeeper.  Sets no watches.
    * @param tableName
    * @throws KeeperException unexpected zookeeper exception
    */
-  public void setEnabledTable(final String tableName)
+  public void setDeletedTable(final String tableName)
   throws KeeperException {
     synchronized (this.cache) {
       if (this.cache.remove(tableName) == null) {
-        LOG.warn("Moving table " + tableName + " state to enabled but was " +
-          "already enabled");
+        LOG.warn("Moving table " + tableName + " state to deleted but was " +
+          "already deleted");
       }
       ZKUtil.deleteNodeFailSilent(this.watcher,
         ZKUtil.joinZNode(this.watcher.tableZNode, tableName));
     }
   }
-
+  /**
+   * Sets the ENABLED state in the cache and deletes the zookeeper node. Fails
+   * silently if the node is not in enabled in zookeeper
+   * 
+   * @param tableName
+   * @throws KeeperException
+   */
+  public void setEnabledTable(final String tableName) throws KeeperException {
+    setTableState(tableName, TableState.ENABLED);
+  }
   /**
    * Gets a list of all the tables set as disabled in zookeeper.
    * @return Set of disabled tables, empty Set if none
@@ -348,4 +415,4 @@ public class ZKTable {
     }
     return disabledTables;
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Sat Jan
14 18:44:33 2012
@@ -137,6 +137,9 @@ public class TestAdmin {
     ht.get(get);
 
     this.admin.disableTable(table);
+    assertTrue("Table must be disabled.", TEST_UTIL.getHbaseCluster()
+        .getMaster().getAssignmentManager().getZKTable().isDisabledTable(
+            Bytes.toString(table)));
 
     // Test that table is disabled
     get = new Get(row);
@@ -151,7 +154,9 @@ public class TestAdmin {
     }
     assertTrue(ok);
     this.admin.enableTable(table);
-
+    assertTrue("Table must be enabled.", TEST_UTIL.getHbaseCluster()
+        .getMaster().getAssignmentManager().getZKTable().isEnabledTable(
+            Bytes.toString(table)));
     // Test that table is enabled
     try {
       ht.get(get);
@@ -989,6 +994,8 @@ public class TestAdmin {
 
     htd.addFamily(hcd);
     admin.createTable(htd, null);
+    assertTrue("Table state must be ENABLED", HTable.isTableEnabled(config,
+        Bytes.toString(TABLENAME)));
     return admin;
   }
   @Test

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java Sat Jan
14 18:44:33 2012
@@ -72,6 +72,8 @@ public class TestMaster {
     HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
 
     TEST_UTIL.createTable(TABLENAME, FAMILYNAME);
+    assertTrue(m.assignmentManager.getZKTable().isEnabledTable
+        (Bytes.toString(TABLENAME)));
     TEST_UTIL.loadTable(new HTable(TEST_UTIL.getConfiguration(), TABLENAME),
       FAMILYNAME);
 
@@ -145,4 +147,4 @@ public class TestMaster {
     public void beforeProcess(EventHandler event) {
     }
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
(original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
Sat Jan 14 18:44:33 2012
@@ -636,7 +636,8 @@ public class TestMasterFailover {
         Bytes.toBytes("iii"), Bytes.toBytes("jjj")
     };
 
-    byte [] enabledTable = Bytes.toBytes("enabledTable");
+    String enabledTableName = "enabledTable";
+    byte [] enabledTable = Bytes.toBytes(enabledTableName);
     HTableDescriptor htdEnabled = new HTableDescriptor(enabledTable);
     htdEnabled.addFamily(new HColumnDescriptor(FAMILY));
     List<HRegionInfo> enabledRegions = TEST_UTIL.createMultiRegionsInMeta(
@@ -682,6 +683,8 @@ public class TestMasterFailover {
       master.assignRegion(hri);
     }
 
+    assertTrue(" Table must be enabled.", master.getAssignmentManager()
+        .getZKTable().isEnabledTable(enabledTableName));
     // we also need regions assigned out on the dead server
     List<HRegionInfo> enabledAndOnDeadRegions = new ArrayList<HRegionInfo>();
     enabledAndOnDeadRegions.add(enabledRegions.remove(0));
@@ -726,6 +729,8 @@ public class TestMasterFailover {
     // Disable the disabledTable in ZK
     ZKTable zktable = new ZKTable(zkw);
     zktable.setDisabledTable(Bytes.toString(disabledTable));
+    assertTrue(" The enabled table should be identified on master fail over.",
+        zktable.isEnabledTable(enabledTableName));
 
     /*
      * ZK = CLOSING

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
(original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
Sat Jan 14 18:44:33 2012
@@ -20,6 +20,7 @@
 package org.apache.hadoop.hbase.master;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.List;
@@ -95,7 +96,9 @@ public class TestMasterRestartAfterDisab
         "stopping the active master so that the backup can become active");
     cluster.hbaseCluster.waitOnMaster(activeMaster);
     cluster.waitForActiveAndReadyMaster();
-
+    assertTrue("The table should not be in enabled state", cluster.getMaster()
+        .getAssignmentManager().getZKTable().isDisablingOrDisabledTable(
+            "tableRestart"));
     log("Enabling table\n");
     TEST_UTIL.getHBaseAdmin().enableTable(table);
     log("Waiting for no more RIT\n");
@@ -105,6 +108,8 @@ public class TestMasterRestartAfterDisab
     assertEquals(
         "The assigned regions were not onlined after master switch except for the catalog
tables.",
         6, regions.size());
+    assertTrue("The table should be in enabled state", cluster.getMaster()
+        .getAssignmentManager().getZKTable().isEnabledTable("tableRestart"));
   }
 
   private void log(String msg) {

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKTable.java?rev=1231555&r1=1231554&r2=1231555&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKTable.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKTable.java Sat
Jan 14 18:44:33 2012
@@ -62,28 +62,42 @@ public class TestZKTable {
     ZooKeeperWatcher zkw = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
       name, abortable);
     ZKTable zkt = new ZKTable(zkw);
-    assertTrue(zkt.isEnabledTable(name));
+    assertFalse(zkt.isEnabledTable(name));
     assertFalse(zkt.isDisablingTable(name));
     assertFalse(zkt.isDisabledTable(name));
     assertFalse(zkt.isEnablingTable(name));
     assertFalse(zkt.isDisablingOrDisabledTable(name));
     assertFalse(zkt.isDisabledOrEnablingTable(name));
+    assertFalse(zkt.isTablePresent(name));
     zkt.setDisablingTable(name);
     assertTrue(zkt.isDisablingTable(name));
     assertTrue(zkt.isDisablingOrDisabledTable(name));
     assertFalse(zkt.getDisabledTables().contains(name));
+    assertTrue(zkt.isTablePresent(name));
     zkt.setDisabledTable(name);
     assertTrue(zkt.isDisabledTable(name));
     assertTrue(zkt.isDisablingOrDisabledTable(name));
     assertFalse(zkt.isDisablingTable(name));
     assertTrue(zkt.getDisabledTables().contains(name));
+    assertTrue(zkt.isTablePresent(name));
     zkt.setEnablingTable(name);
     assertTrue(zkt.isEnablingTable(name));
     assertTrue(zkt.isDisabledOrEnablingTable(name));
     assertFalse(zkt.isDisabledTable(name));
     assertFalse(zkt.getDisabledTables().contains(name));
+    assertTrue(zkt.isTablePresent(name));
     zkt.setEnabledTable(name);
     assertTrue(zkt.isEnabledTable(name));
     assertFalse(zkt.isEnablingTable(name));
+    assertTrue(zkt.isTablePresent(name));
+    zkt.setDeletedTable(name);
+    assertFalse(zkt.isEnabledTable(name));
+    assertFalse(zkt.isDisablingTable(name));
+    assertFalse(zkt.isDisabledTable(name));
+    assertFalse(zkt.isEnablingTable(name));
+    assertFalse(zkt.isDisablingOrDisabledTable(name));
+    assertFalse(zkt.isDisabledOrEnablingTable(name));
+    assertFalse(zkt.isTablePresent(name));
+    
   }
 }



Mime
View raw message