HBASE-3575 Update rename table script

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1084062 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-03-22 03:18:12 +00:00
parent 2147902eab
commit bb28add83e
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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()