You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/03/22 04:18:12 UTC

svn commit: r1084062 - in /hbase/trunk: CHANGES.txt bin/rename_table.rb

Author: stack
Date: Tue Mar 22 03:18:12 2011
New Revision: 1084062

URL: http://svn.apache.org/viewvc?rev=1084062&view=rev
Log:
HBASE-3575 Update rename table script

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/bin/rename_table.rb

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1084062&r1=1084061&r2=1084062&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Mar 22 03:18:12 2011
@@ -157,6 +157,7 @@ Release 0.90.2 - Unreleased
                logs; else we replay split on every restart
    HBASE-3621  The timeout handler in AssignmentManager does an RPC while
                holding lock on RIT; a big no-no (Ted Yu via Stack)
+   HBASE-3575  Update rename table script
 
   IMPROVEMENTS
    HBASE-3542  MultiGet methods in Thrift

Modified: hbase/trunk/bin/rename_table.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/bin/rename_table.rb?rev=1084062&r1=1084061&r2=1084062&view=diff
==============================================================================
--- hbase/trunk/bin/rename_table.rb (original)
+++ hbase/trunk/bin/rename_table.rb Tue Mar 22 03:18:12 2011
@@ -95,7 +95,7 @@ oldTableName = ARGV[0]
 newTableName = ARGV[1]
 
 # Get configuration to use.
-c = HBaseConfiguration.new()
+c = HBaseConfiguration.create()
 
 # Set hadoop filesystem configuration using the hbase.rootdir.
 # Otherwise, we'll always use localhost though the hbase.rootdir
@@ -147,13 +147,20 @@ while (result = scanner.next())
     d = Delete.new(result.getRow())
     metaTable.delete(d)
     # Create 'new' region
-    newR = HRegion.new(rootdir, nil, fs, c, newHRI, nil)
+    newR = HRegion.new(newTableDir, nil, fs, c, newHRI, nil)
     # Add new row. NOTE: Presumption is that only one .META. region. If not,
     # need to do the work to figure proper region to add this new region to.
     LOG.info("Adding to meta: " + newR.toString())
+    bytes = Writables.getBytes(newR.getRegionInfo())
     p = Put.new(newR.getRegionName())
-    p.add(HConstants::CATALOG_FAMILY, HConstants::REGIONINFO_QUALIFIER, Writables.getBytes(newR.getRegionInfo()))
+    p.add(HConstants::CATALOG_FAMILY, HConstants::REGIONINFO_QUALIFIER, bytes)
     metaTable.put(p)
+    # Finally update the .regioninfo under new region location so it has new name.
+    regioninfofile =  Path.new(newR.getRegionDir(), HRegion::REGIONINFO_FILE)
+    fs.delete(regioninfofile, true)
+    out = fs.create(regioninfofile)
+    newR.getRegionInfo().write(out)
+    out.close()
   end
 end
 scanner.close()