hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r797851 - in /hadoop/hbase/trunk: CHANGES.txt bin/HBase.rb src/java/org/apache/hadoop/hbase/master/HMaster.java src/java/org/apache/hadoop/hbase/master/RegionManager.java
Date Sat, 25 Jul 2009 23:14:16 GMT
Author: stack
Date: Sat Jul 25 23:14:16 2009
New Revision: 797851

URL: http://svn.apache.org/viewvc?rev=797851&view=rev
Log:
HBASE-1693 NPE close_region .META. in shell

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/bin/HBase.rb
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=797851&r1=797850&r2=797851&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Sat Jul 25 23:14:16 2009
@@ -284,6 +284,7 @@
                defined types (Clint Morgan via Stack and Jon Gray)
    HBASE-1607  transactions / indexing fixes: trx deletes not handeled, index
                scan can't specify stopRow (Clint Morgan via Stack)
+   HBASE-1693  NPE close_region ".META." in shell
 
   IMPROVEMENTS
    HBASE-1089  Add count of regions on filesystem to master UI; add percentage

Modified: hadoop/hbase/trunk/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/HBase.rb?rev=797851&r1=797850&r2=797851&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/HBase.rb (original)
+++ hadoop/hbase/trunk/bin/HBase.rb Sat Jul 25 23:14:16 2009
@@ -13,6 +13,8 @@
 
 import org.apache.hadoop.hbase.client.HBaseAdmin
 import org.apache.hadoop.hbase.client.HTable
+import org.apache.hadoop.hbase.client.Get
+import org.apache.hadoop.hbase.client.Put
 import org.apache.hadoop.hbase.client.Delete
 import org.apache.hadoop.hbase.HConstants
 import org.apache.hadoop.hbase.io.BatchUpdate
@@ -144,13 +146,16 @@
       now = Time.now 
       meta = HTable.new(HConstants::META_TABLE_NAME)
       bytes = Bytes.toBytes(regionName)
-      hriBytes = meta.get(bytes, HConstants::COL_REGIONINFO).getValue()
+      g = Get.new(bytes)
+      g.addColumn(HConstants::CATALOG_FAMILY,
+        HConstants::REGIONINFO_QUALIFIER)
+      hriBytes = meta.get(g).value()
       hri = Writables.getWritable(hriBytes, HRegionInfo.new());
       hri.setOffline(onOrOff)
-      p hri
-      bu = BatchUpdate.new(bytes)
-      bu.put(HConstants::COL_REGIONINFO, Writables.getBytes(hri))
-      meta.commit(bu);
+      put = Put.new(bytes)
+      put.add(HConstants::CATALOG_FAMILY,
+        HConstants::REGIONINFO_QUALIFIER, Writables.getBytes(hri))
+      meta.put(put);
       @formatter.header()
       @formatter.footer(now)
     end

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=797851&r1=797850&r2=797851&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Sat Jul 25 23:14:16
2009
@@ -950,10 +950,8 @@
   throws IOException {
     MetaRegion meta = this.regionManager.getMetaRegionForRow(row);
     HRegionInterface srvr = getMETAServer(meta);
-
     Get get = new Get(row);
     get.addFamily(family);
-    
     return srvr.get(meta.getRegionName(), get);
   }
   

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=797851&r1=797850&r2=797851&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 Sat Jul
25 23:14:16 2009
@@ -82,6 +82,8 @@
     new ConcurrentSkipListMap<byte [], MetaRegion>(Bytes.BYTES_COMPARATOR);
 
   private static final byte[] OVERLOADED = Bytes.toBytes("Overloaded");
+  
+  private static final byte [] META_REGION_PREFIX = Bytes.toBytes(".META.,");
 
   /**
    * Map of region name to RegionState for regions that are in transition such as
@@ -692,7 +694,7 @@
   /**
    * Get metaregion that would host passed in row.
    * @param row Row need to know all the meta regions for
-   * @return set of MetaRegion objects that contain the table
+   * @return MetaRegion for passed row.
    * @throws NotAllMetaRegionsOnlineException
    */
   public MetaRegion getMetaRegionForRow(final byte [] row)
@@ -700,6 +702,12 @@
     if (!areAllMetaRegionsOnline()) {
       throw new NotAllMetaRegionsOnlineException();
     }
+    // Row might be in -ROOT- table.  If so, return -ROOT- region.
+    int prefixlen = META_REGION_PREFIX.length;
+    if (row.length > prefixlen &&
+     Bytes.compareTo(META_REGION_PREFIX, 0, prefixlen, row, 0, prefixlen) == 0) {
+    	return new MetaRegion(this.master.getRootRegionLocation(), HRegionInfo.ROOT_REGIONINFO);
+    }
     return this.onlineMetaRegions.floorEntry(row).getValue();
   }
 



Mime
View raw message