hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r893379 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/master/ src/java/org/apache/hadoop/hbase/regionserver/wal/ src/test/ src/test/org/apache/hadoop/hbase/client/
Date Wed, 23 Dec 2009 02:39:09 GMT
Author: jdcryans
Date: Wed Dec 23 02:39:03 2009
New Revision: 893379

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

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
    hadoop/hbase/trunk/src/test/hbase-site.xml
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=893379&r1=893378&r2=893379&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed Dec 23 02:39:03 2009
@@ -135,6 +135,10 @@
                hbase.version
    HBASE-2054  memstore size 0 is >= than blocking -2.0g size
    HBASE-2057  Cluster won't stop
+   HBASE-2064  Cannot disable a table if at the same the Master is moving 
+               its regions around
+   HBASE-2065  Cannot disable a table if any of its region is opening 
+               at the same time
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java?rev=893379&r1=893378&r2=893379&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java Wed
Dec 23 02:39:03 2009
@@ -103,8 +103,15 @@
           master.getRegionManager().metaScannerThread.interrupt();
         }
       }
-      // If updated successfully, remove from pending list.
-      master.getRegionManager().removeRegion(regionInfo);
+      // If updated successfully, remove from pending list if the state
+      // is consistent. For example, a disable could be called before the
+      // synchronization.
+      if(master.getRegionManager().
+          isOfflined(regionInfo.getRegionNameAsString())) {
+        LOG.warn("We opened a region while it was asked to be closed.");
+      } else {
+        master.getRegionManager().removeRegion(regionInfo);
+      }
       return true;
     }
   }

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=893379&r1=893378&r2=893379&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java Wed Dec
23 02:39:03 2009
@@ -945,7 +945,7 @@
         s = new RegionState(info);
         regionsInTransition.put(info.getRegionNameAsString(), s);
       }
-      if (force || (!s.isPendingOpen() && !s.isOpen())) {
+      if (force || (!s.isPendingOpen() || !s.isOpen())) {
         s.setUnassigned();
       }
     }
@@ -1018,7 +1018,7 @@
    * @param regionInfo
    * @param setOffline
    */
-  public void setClosing(final String serverName, final HRegionInfo regionInfo,
+  public void setClosing(String serverName, final HRegionInfo regionInfo,
       final boolean setOffline) {
     synchronized (this.regionsInTransition) {
       RegionState s =
@@ -1026,6 +1026,11 @@
       if (s == null) {
         s = new RegionState(regionInfo);
       }
+      // If region was asked to open before getting here, we could be taking
+      // the wrong server name
+      if(s.isPendingOpen()) {
+        serverName = s.getServerName();
+      }
       s.setClosing(serverName, setOffline);
       this.regionsInTransition.put(regionInfo.getRegionNameAsString(), s);
     }
@@ -1595,10 +1600,10 @@
     }
     
     synchronized void setClosed() {
-      if (!pendingClose && !pendingOpen) {
+      if (!pendingClose && !pendingOpen && !closing) {
         throw new IllegalStateException(
             "Cannot set a region to be closed if it was not already marked as" +
-            " pending close or pending open. State: " + toString());
+            " pending close, pending open or closing. State: " + toString());
       }
       this.unassigned = false;
       this.pendingOpen = false;

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=893379&r1=893378&r2=893379&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java Wed Dec
23 02:39:03 2009
@@ -789,11 +789,6 @@
     }
     try {
       this.editsSize.addAndGet(logKey.heapSize() + logEdit.heapSize());
-      if (LOG.isDebugEnabled() && 
-          (this.numEntries.get() % this.flushlogentries == 0)) {
-        LOG.debug("edit=" + this.numEntries.get() + ", write=" +
-          logKey.toString());
-      }
       this.writer.append(new HLog.Entry(logKey, logEdit));
       long took = System.currentTimeMillis() - now;
       if (took > 1000) {

Modified: hadoop/hbase/trunk/src/test/hbase-site.xml
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/hbase-site.xml?rev=893379&r1=893378&r2=893379&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/hbase-site.xml (original)
+++ hadoop/hbase/trunk/src/test/hbase-site.xml Wed Dec 23 02:39:03 2009
@@ -99,7 +99,7 @@
   </property>
   <property>
     <name>hbase.regionserver.optionalcacheflushinterval</name>
-    <value>10000</value>
+    <value>1000</value>
     <description>
     Amount of time to wait since the last time a region was flushed before
     invoking an optional cache flush. Default 60,000.

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=893379&r1=893378&r2=893379&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 Wed Dec 23 02:39:03
2009
@@ -22,6 +22,7 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.Map;
@@ -44,6 +45,7 @@
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+
 /**
  * Class to test HBaseAdmin.
  * Spins up the minicluster once at test start and then takes it down afterward.
@@ -56,6 +58,9 @@
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
+    TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
+    TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
+    TEST_UTIL.getConfiguration().setInt("hbase.client.retries.number", 6);
     TEST_UTIL.startMiniCluster(3);
   }
 
@@ -103,7 +108,7 @@
     }
     assertEquals(true, ok);
     this.admin.enableTable(table);
-    
+
     //Test that table is enabled
     try {
       ht.get(get);
@@ -112,7 +117,7 @@
     }
     assertEquals(true, ok);
   }
-  
+
   @Test
   public void testTableExist() throws IOException {
     final byte [] table = Bytes.toBytes("testTableExist");
@@ -126,7 +131,7 @@
 
   /**
    * Tests forcing split from client and having scanners successfully ride over split.
-   * @throws Exception 
+   * @throws Exception
    * @throws IOException
    */
   @Test
@@ -164,7 +169,7 @@
     }
     scanner.close();
     assertEquals(rowCount, rows);
-    
+
     // Have an outstanding scan going on to make sure we can scan over splits.
     scan = new Scan();
     scanner = table.getScanner(scan);
@@ -337,7 +342,7 @@
   /**
    * Test that user table names can contain '-' and '.' so long as they do not
    * start with same. HBASE-771
-   * @throws IOException 
+   * @throws IOException
    */
   @Test
   public void testTableNames() throws IOException {
@@ -368,7 +373,7 @@
 
   /**
    * For HADOOP-2579
-   * @throws IOException 
+   * @throws IOException
    */
   @Test (expected=TableExistsException.class)
   public void testTableNotFoundExceptionWithATable() throws IOException {
@@ -379,11 +384,34 @@
 
   /**
    * For HADOOP-2579
-   * @throws IOException 
+   * @throws IOException
    */
   @Test (expected=TableNotFoundException.class)
   public void testTableNotFoundExceptionWithoutAnyTables() throws IOException {
     new HTable(TEST_UTIL.getConfiguration(),
         "testTableNotFoundExceptionWithoutAnyTables");
   }
-}
\ No newline at end of file
+
+  @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");
+
+    for(int i = 0; i < times; i++) {
+      HTableDescriptor htd = new HTableDescriptor("table"+i);
+      htd.addFamily(fam1);
+      htd.addFamily(fam2);
+      htd.addFamily(fam3);
+      this.admin.createTable(htd);
+    }
+
+    for(int i = 0; i < times; i++) {
+      String tableName = "table"+i;
+      this.admin.disableTable(tableName);
+      this.admin.deleteTable(tableName);
+    }
+  }
+}



Mime
View raw message