hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r817784 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/master/RegionManager.java src/test/org/apache/hadoop/hbase/master/TestRegionManager.java
Date Tue, 22 Sep 2009 19:23:17 GMT
Author: stack
Date: Tue Sep 22 19:23:11 2009
New Revision: 817784

URL: http://svn.apache.org/viewvc?rev=817784&view=rev
Log:
HBASE-1857 WrongRegionException when setting region online after .META. split

Added:
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/master/TestRegionManager.java
Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=817784&r1=817783&r2=817784&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Tue Sep 22 19:23:11 2009
@@ -25,6 +25,8 @@
                to contact a failed regionserver
    HBASE-1856  HBASE-1765 broke MapReduce when using Result.list()
                (Lars George via Stack)
+   HBASE-1857  WrongRegionException when setting region online after .META.
+               split (Cosmin Lehane via Stack)
 
   IMPROVEMENTS
    HBASE-1819  Update to 0.20.1 hadoop and zk 3.2.1

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=817784&r1=817783&r2=817784&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java
Tue Sep 22 19:23:11 2009
@@ -622,7 +622,7 @@
           return onlineMetaRegions.get(newRegion.getRegionName());
         } 
         return onlineMetaRegions.get(onlineMetaRegions.headMap(
-            newRegion.getTableDesc().getName()).lastKey());
+            newRegion.getRegionName()).lastKey());
       }
     }
   }

Added: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/master/TestRegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/master/TestRegionManager.java?rev=817784&view=auto
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/master/TestRegionManager.java
(added)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/master/TestRegionManager.java
Tue Sep 22 19:23:11 2009
@@ -0,0 +1,69 @@
+package org.apache.hadoop.hbase.master;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.HBaseClusterTestCase;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseTestCase;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.util.StringUtils;
+
+public class TestRegionManager extends HBaseClusterTestCase {
+   public void testGetFirstMetaRegionForRegionAfterMetaSplit()
+   throws Exception {
+     HTable meta = new HTable(HConstants.META_TABLE_NAME);
+     HMaster master = this.cluster.getMaster();
+     HServerAddress address = master.getMasterAddress();
+     HTableDescriptor tableDesc = new HTableDescriptor(Bytes.toBytes("_MY_TABLE_"));
+     HTableDescriptor metaTableDesc = meta.getTableDescriptor();
+     // master.regionManager.onlineMetaRegions already contains first .META. region at key
Bytes.toBytes("")
+     byte[] startKey0 = Bytes.toBytes("f");
+     byte[] endKey0 = Bytes.toBytes("h");
+     HRegionInfo regionInfo0 = new HRegionInfo(tableDesc, startKey0, endKey0);
+
+     // 1st .META. region will be something like .META.,,1253625700761
+     HRegionInfo metaRegionInfo0 = new HRegionInfo(metaTableDesc, Bytes.toBytes(""), regionInfo0.getRegionName());
+     MetaRegion meta0 = new MetaRegion(address, metaRegionInfo0);
+   
+     byte[] startKey1 = Bytes.toBytes("j");
+     byte[] endKey1 = Bytes.toBytes("m");
+     HRegionInfo regionInfo1 = new HRegionInfo(tableDesc, startKey1, endKey1);
+     // 2nd .META. region will be something like .META.,_MY_TABLE_,f,1253625700761,1253625700761

+     HRegionInfo metaRegionInfo1 = new HRegionInfo(metaTableDesc, regionInfo0.getRegionName(),
regionInfo1.getRegionName());
+     MetaRegion meta1 = new MetaRegion(address, metaRegionInfo1);
+
+
+     // 3rd .META. region will be something like .META.,_MY_TABLE_,j,1253625700761,1253625700761
+     HRegionInfo metaRegionInfo2 = new HRegionInfo(metaTableDesc, regionInfo1.getRegionName(),
Bytes.toBytes(""));
+     MetaRegion meta2 = new MetaRegion(address, metaRegionInfo2);
+
+     byte[] startKeyX = Bytes.toBytes("h");
+     byte[] endKeyX = Bytes.toBytes("j");
+     HRegionInfo regionInfoX = new HRegionInfo(tableDesc, startKeyX, endKeyX);
+   
+   
+     master.regionManager.offlineMetaRegion(startKey0);
+     master.regionManager.putMetaRegionOnline(meta0);
+     master.regionManager.putMetaRegionOnline(meta1);
+     master.regionManager.putMetaRegionOnline(meta2);
+   
+//    for (byte[] b : master.regionManager.getOnlineMetaRegions().keySet()) {
+//      System.out.println("FROM TEST KEY " + b +"  " +new String(b));
+//    }
+
+     assertEquals(metaRegionInfo1.getStartKey(), master.regionManager.getFirstMetaRegionForRegion(regionInfoX).getStartKey());
+     assertEquals(metaRegionInfo1.getRegionName(), master.regionManager.getFirstMetaRegionForRegion(regionInfoX).getRegionName());
+   }
+}



Mime
View raw message