HBASE-7742 [snapshot 130201 merge] Fix TestHFileArchiving#testArchiveOnTableDelete

With the merge, we were using the new move to .tmp then archive table deletion code but archived to the incorrect directory.



git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-7290v2@1446150 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2013-02-14 13:01:12 +00:00
parent b96a70d70d
commit 11604eed26
5 changed files with 22 additions and 22 deletions

View File

@ -73,13 +73,12 @@ public class HFileArchiver {
public static void archiveRegion(Configuration conf, FileSystem fs, HRegionInfo info)
throws IOException {
Path rootDir = FSUtils.getRootDir(conf);
archiveRegion(conf, fs, rootDir, HTableDescriptor.getTableDir(rootDir, info.getTableName()),
archiveRegion(fs, rootDir, HTableDescriptor.getTableDir(rootDir, info.getTableName()),
HRegion.getRegionDir(rootDir, info));
}
/**
* Remove an entire region from the table directory via archiving the region's hfiles.
* @param conf the configuration to use
* @param fs {@link FileSystem} from which to remove the region
* @param rootdir {@link Path} to the root directory where hbase files are stored (for building
* the archive path)
@ -89,8 +88,7 @@ public class HFileArchiver {
* operations could not complete.
* @throws IOException if the request cannot be completed
*/
public static boolean archiveRegion(Configuration conf, FileSystem fs,
Path rootdir, Path tableDir, Path regionDir)
public static boolean archiveRegion(FileSystem fs, Path rootdir, Path tableDir, Path regionDir)
throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("ARCHIVING region " + regionDir.toString());
@ -109,7 +107,7 @@ public class HFileArchiver {
// make sure the regiondir lives under the tabledir
Preconditions.checkArgument(regionDir.toString().startsWith(tableDir.toString()));
Path regionArchiveDir = HFileArchiveUtil.getRegionArchiveDir(conf, tableDir, regionDir);
Path regionArchiveDir = HFileArchiveUtil.getRegionArchiveDir(rootdir, tableDir, regionDir);
LOG.debug("Have an archive directory, preparing to move files");
FileStatusConverter getAsFile = new FileStatusConverter(fs);

View File

@ -464,7 +464,7 @@ public class MasterFileSystem {
// if not the cleaner will take care of them.
for (Path tabledir: FSUtils.getTableDirs(fs, tmpdir)) {
for (Path regiondir: FSUtils.getRegionDirs(fs, tabledir)) {
HFileArchiver.archiveRegion(c, fs, this.rootdir, tabledir, regiondir);
HFileArchiver.archiveRegion(fs, this.rootdir, tabledir, regiondir);
}
}
if (!fs.delete(tmpdir, true)) {

View File

@ -87,22 +87,24 @@ public class DeleteTableHandler extends TableEventHandler {
MasterFileSystem mfs = this.masterServices.getMasterFileSystem();
Path tempTableDir = mfs.moveTableToTemp(tableName);
// 4. Update table descriptor cache
this.masterServices.getTableDescriptors().remove(Bytes.toString(tableName));
// 5. If entry for this table in zk, and up in AssignmentManager, remove it.
am.getZKTable().setDeletedTable(Bytes.toString(tableName));
// 6. Delete regions from FS (temp directory)
try {
// 4. Delete regions from FS (temp directory)
FileSystem fs = mfs.getFileSystem();
for (HRegionInfo hri: regions) {
LOG.debug("Deleting region " + hri.getRegionNameAsString() + " from FS");
HFileArchiver.archiveRegion(masterServices.getConfiguration(), fs, mfs.getRootDir(),
HFileArchiver.archiveRegion(fs, mfs.getRootDir(),
tempTableDir, new Path(tempTableDir, hri.getEncodedName()));
}
// 7. Delete table from FS (temp directory)
// 5. Delete table from FS (temp directory)
fs.delete(tempTableDir, true);
} finally {
// 6. Update table descriptor cache
this.masterServices.getTableDescriptors().remove(Bytes.toString(tableName));
// 7. If entry for this table in zk, and up in AssignmentManager, remove it.
am.getZKTable().setDeletedTable(Bytes.toString(tableName));
}
if (cpHost != null) {
cpHost.postDeleteTableHandler(this.tableName);

View File

@ -4374,10 +4374,10 @@ public class HRegion implements HeapSize { // , Writable{
}
// delete out the 'A' region
HFileArchiver.archiveRegion(a.getBaseConf(), fs,
HFileArchiver.archiveRegion(fs,
FSUtils.getRootDir(a.getBaseConf()), a.getTableDir(), a.getRegionDir());
// delete out the 'B' region
HFileArchiver.archiveRegion(a.getBaseConf(), fs,
HFileArchiver.archiveRegion(fs,
FSUtils.getRootDir(b.getBaseConf()), b.getTableDir(), b.getRegionDir());
LOG.info("merge completed. New region is " + dstRegion);

View File

@ -358,7 +358,7 @@ public class TestHFileArchiving {
try {
// Try to archive the file
HFileArchiver.archiveRegion(conf, fs, rootDir,
HFileArchiver.archiveRegion(fs, rootDir,
sourceRegionDir.getParent(), sourceRegionDir);
// The archiver succeded, the file is no longer in the original location