hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r893675 - in /hadoop/hbase/trunk/src: java/org/apache/hadoop/hbase/client/ java/org/apache/hadoop/hbase/master/ java/org/apache/hadoop/hbase/regionserver/ test/org/apache/hadoop/hbase/client/
Date Thu, 24 Dec 2009 01:23:08 GMT
Author: jdcryans
Date: Thu Dec 24 01:23:07 2009
New Revision: 893675

URL: http://svn.apache.org/viewvc?rev=893675&view=rev
Log:
HBASE-2065 Cannot disable a table if any of its region is opening at the same time

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=893675&r1=893674&r2=893675&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Thu Dec 24
01:23:07 2009
@@ -326,15 +326,16 @@
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    try {
-      this.master.enableTable(tableName);
-    } catch (RemoteException e) {
-      throw RemoteExceptionHandler.decodeRemoteException(e);
-    }
 
     // Wait until all regions are enabled
     boolean enabled = false;
     for (int tries = 0; tries < this.numRetries; tries++) {
+
+      try {
+        this.master.enableTable(tableName);
+      } catch (RemoteException e) {
+        throw RemoteExceptionHandler.decodeRemoteException(e);
+      }
       enabled = isTableEnabled(tableName);
       if (enabled) break;
       long sleep = getPauseTime(tries);
@@ -382,15 +383,15 @@
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    try {
-      this.master.disableTable(tableName);
-    } catch (RemoteException e) {
-      throw RemoteExceptionHandler.decodeRemoteException(e);
-    }
 
     // Wait until all regions are disabled
     boolean disabled = false;
     for (int tries = 0; tries < this.numRetries; tries++) {
+      try {
+        this.master.disableTable(tableName);
+      } catch (RemoteException e) {
+        throw RemoteExceptionHandler.decodeRemoteException(e);
+      }
       disabled = isTableDisabled(tableName);
       if (disabled) break;
       if (LOG.isDebugEnabled()) {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java?rev=893675&r1=893674&r2=893675&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java Thu Dec
24 01:23:07 2009
@@ -78,6 +78,13 @@
         continue;
       }
 
+      if(!this.online && this.master.getRegionManager().
+          isPendingOpen(i.getRegionNameAsString())) {
+        LOG.debug("Skipping region " + i.toString() +
+          " because it is pending open, will tell it to close later");
+        continue;
+      }
+
       // Update meta table
       Put put = updateRegionInfo(i);
       server.put(m.getRegionName(), put);

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java?rev=893675&r1=893674&r2=893675&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionClose.java Thu
Dec 24 01:23:07 2009
@@ -59,11 +59,11 @@
   @Override
   protected boolean process() throws IOException {
     Boolean result = null;
-    if (offlineRegion) {
+    if (offlineRegion || reassignRegion) {
       result =
         new RetryableMetaOperation<Boolean>(getMetaRegion(), this.master) {
           public Boolean call() throws IOException {
-            LOG.info("region closed: " + regionInfo.getRegionNameAsString());
+
 
             // We can't proceed unless the meta region we are going to update
             // is online. metaRegionAvailable() will put this operation on the
@@ -71,21 +71,27 @@
             // back on the toDoQueue
 
             if (metaRegionAvailable()) {
-              // offline the region in meta and then remove it from the
-              // set of regions in transition
-              HRegion.offlineRegionInMETA(server, metaRegionName,
-                  regionInfo);
-              master.getRegionManager().removeRegion(regionInfo);
+              if(offlineRegion) {
+                // offline the region in meta and then remove it from the
+                // set of regions in transition
+                HRegion.offlineRegionInMETA(server, metaRegionName,
+                    regionInfo);
+                master.getRegionManager().removeRegion(regionInfo);
+                LOG.info("region closed: " + regionInfo.getRegionNameAsString());
+              } else {
+                // we are reassigning the region eventually, so set it unassigned
+                // and remove the server info
+                HRegion.cleanRegionInMETA(server, metaRegionName,
+                    regionInfo);
+                master.getRegionManager().setUnassigned(regionInfo, false);
+                LOG.info("region set as unassigned: " + regionInfo.getRegionNameAsString());
+              }
             }
             return true;
           }
         }.doWithRetries();
         result = result == null ? true : result;
 
-    } else if (reassignRegion) {
-      LOG.info("region set as unassigned: " + regionInfo.getRegionNameAsString());
-      // we are reassigning the region eventually, so set it unassigned
-      master.getRegionManager().setUnassigned(regionInfo, false);
     } else {
       LOG.info("Region was neither offlined, or asked to be reassigned, what gives: " +
       regionInfo.getRegionNameAsString());

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=893675&r1=893674&r2=893675&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Thu Dec
24 01:23:07 2009
@@ -1925,9 +1925,7 @@
 
   /**
    * Delete a region's meta information from the passed
-   * <code>meta</code> region.  Removes content in the 'info' column family.
-   * Does not remove region historian info.
-   * 
+   * <code>meta</code> region.  Deletes the row.
    * @param srvr META server to be updated
    * @param metaRegionName Meta region name
    * @param regionName HRegion to remove from <code>meta</code>
@@ -1938,7 +1936,6 @@
     final byte [] metaRegionName, final byte [] regionName)
   throws IOException {
     Delete delete = new Delete(regionName);
-    delete.deleteFamily(HConstants.CATALOG_FAMILY);
     srvr.delete(metaRegionName, delete);
   }
 
@@ -1961,10 +1958,7 @@
     info.setOffline(true);
     put.add(CATALOG_FAMILY, REGIONINFO_QUALIFIER, Writables.getBytes(info));
     srvr.put(metaRegionName, put);
-    Delete del = new Delete(row);
-    del.deleteColumns(CATALOG_FAMILY, SERVER_QUALIFIER);
-    del.deleteColumns(CATALOG_FAMILY, STARTCODE_QUALIFIER);
-    srvr.delete(metaRegionName, del);
+    cleanRegionInMETA(srvr, metaRegionName, info);
   }
   
   /**

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java?rev=893675&r1=893674&r2=893675&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java Thu Dec 24 01:23:07
2009
@@ -395,7 +395,6 @@
   @Test
   public void testHundredsOfTable() throws IOException{
     final int times = 100;
-    byte [] name = Bytes.toBytes("testHundredsOfTable");
     HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
     HColumnDescriptor fam2 = new HColumnDescriptor("fam2");
     HColumnDescriptor fam3 = new HColumnDescriptor("fam3");
@@ -411,6 +410,8 @@
     for(int i = 0; i < times; i++) {
       String tableName = "table"+i;
       this.admin.disableTable(tableName);
+      this.admin.enableTable(tableName);
+      this.admin.disableTable(tableName);
       this.admin.deleteTable(tableName);
     }
   }



Mime
View raw message