Index: bin/HBase.rb =================================================================== --- bin/HBase.rb (revision 797847) +++ bin/HBase.rb (working copy) @@ -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 Index: src/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/HMaster.java (revision 797847) +++ src/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -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); } Index: src/java/org/apache/hadoop/hbase/master/RegionManager.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/RegionManager.java (revision 797847) +++ src/java/org/apache/hadoop/hbase/master/RegionManager.java (working copy) @@ -82,6 +82,8 @@ new ConcurrentSkipListMap(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(); }