Stack,

This script does work from one perspective.  It makes an entry in the .meta. 
table with the missing region.  But it does not create a region file for it.  
How does one go about doing that?

Thanks,
Robert

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stack
Sent: Tuesday, May 31, 2011 6:39 PM
To: [email protected]
Subject: Re: wrong region exception

On Tue, May 31, 2011 at 3:34 PM, Robert Gonzalez 
<[email protected]> wrote:
> The script doesn't work because it attempts to fix the hole by finding a 
> region in the hdfs filesystem that fills the hole.  But in this case there is 
> no such file.  The hole is just there.
>

OK.  The fixup method has the left and right edges.  Could use previous rows 
regioninfo and adjust it to fill the hole (or create a new one)?  Something 
like the below?


diff --git a/bin/check_meta.rb b/bin/check_meta.rb index d874922..82c6ac0 100644
--- a/bin/check_meta.rb
+++ b/bin/check_meta.rb
@@ -80,32 +80,12 @@ def getConfiguration  end

 def fixup(leftEdge, rightEdge, metatable, fs, rootdir)
-  plugged = nil
-  # Try and fix the passed holes in meta.
-  tabledir = HTableDescriptor::getTableDir(rootdir,
leftEdge.getTableDesc().getName())
-  statuses = fs.listStatus(tabledir)
-  for status in statuses
-    next unless status.isDir()
-    next if status.getPath().getName() == "compaction.dir"
-    regioninfofile =  Path.new(status.getPath(), ".regioninfo")
-    unless fs.exists(regioninfofile)
-      LOG.warn("Missing .regioninfo: " + regioninfofile.toString())
-      next
-    end
-    is = fs.open(regioninfofile)
-    hri = HRegionInfo.new()
-    hri.readFields(is)
-    is.close()
-    next unless Bytes.equals(leftEdge.getEndKey(), hri.getStartKey())
-    # TODO: Check against right edge to make sure this addition does
not overflow right edge.
-    # TODO: Check that the schema matches both left and right edges schemas.
-    p = Put.new(hri.getRegionName())
-    p.add(HConstants::CATALOG_FAMILY,
HConstants::REGIONINFO_QUALIFIER, Writables.getBytes(hri))
-    metatable.put(p)
-    LOG.info("Plugged hole in .META. at: " + hri.toString())
-    plugged = true
-  end
-  return plugged
+  hri = HRegionInfo.new(leftEdge.getTableDesc(),
leftEdge.getEndRow(), rightEdge.getStartRow())
+  p = Put.new(hri.getRegionName())
+  p.add(HConstants::CATALOG_FAMILY, HConstants::REGIONINFO_QUALIFIER,
Writables.getBytes(hri))
+  metatable.put(p)
+  LOG.info("Plugged hole in .META. at: " + hri.toString())  return true
 end

 fixup = isFixup()


St.Ack

Reply via email to