hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1084063 - in /hbase/branches/0.90: CHANGES.txt bin/rename_table.rb
Date Tue, 22 Mar 2011 03:18:50 GMT
Author: stack
Date: Tue Mar 22 03:18:50 2011
New Revision: 1084063

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

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/bin/rename_table.rb

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1084063&r1=1084062&r2=1084063&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Tue Mar 22 03:18:50 2011
@@ -46,6 +46,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/branches/0.90/bin/rename_table.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/bin/rename_table.rb?rev=1084063&r1=1084062&r2=1084063&view=diff
==============================================================================
--- hbase/branches/0.90/bin/rename_table.rb (original)
+++ hbase/branches/0.90/bin/rename_table.rb Tue Mar 22 03:18:50 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()



Mime
View raw message