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:
parent
b96a70d70d
commit
11604eed26
|
@ -73,13 +73,12 @@ public class HFileArchiver {
|
||||||
public static void archiveRegion(Configuration conf, FileSystem fs, HRegionInfo info)
|
public static void archiveRegion(Configuration conf, FileSystem fs, HRegionInfo info)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Path rootDir = FSUtils.getRootDir(conf);
|
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));
|
HRegion.getRegionDir(rootDir, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an entire region from the table directory via archiving the region's hfiles.
|
* 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 fs {@link FileSystem} from which to remove the region
|
||||||
* @param rootdir {@link Path} to the root directory where hbase files are stored (for building
|
* @param rootdir {@link Path} to the root directory where hbase files are stored (for building
|
||||||
* the archive path)
|
* the archive path)
|
||||||
|
@ -89,8 +88,7 @@ public class HFileArchiver {
|
||||||
* operations could not complete.
|
* operations could not complete.
|
||||||
* @throws IOException if the request cannot be completed
|
* @throws IOException if the request cannot be completed
|
||||||
*/
|
*/
|
||||||
public static boolean archiveRegion(Configuration conf, FileSystem fs,
|
public static boolean archiveRegion(FileSystem fs, Path rootdir, Path tableDir, Path regionDir)
|
||||||
Path rootdir, Path tableDir, Path regionDir)
|
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("ARCHIVING region " + regionDir.toString());
|
LOG.debug("ARCHIVING region " + regionDir.toString());
|
||||||
|
@ -109,7 +107,7 @@ public class HFileArchiver {
|
||||||
|
|
||||||
// make sure the regiondir lives under the tabledir
|
// make sure the regiondir lives under the tabledir
|
||||||
Preconditions.checkArgument(regionDir.toString().startsWith(tableDir.toString()));
|
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");
|
LOG.debug("Have an archive directory, preparing to move files");
|
||||||
FileStatusConverter getAsFile = new FileStatusConverter(fs);
|
FileStatusConverter getAsFile = new FileStatusConverter(fs);
|
||||||
|
|
|
@ -464,7 +464,7 @@ public class MasterFileSystem {
|
||||||
// if not the cleaner will take care of them.
|
// if not the cleaner will take care of them.
|
||||||
for (Path tabledir: FSUtils.getTableDirs(fs, tmpdir)) {
|
for (Path tabledir: FSUtils.getTableDirs(fs, tmpdir)) {
|
||||||
for (Path regiondir: FSUtils.getRegionDirs(fs, tabledir)) {
|
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)) {
|
if (!fs.delete(tmpdir, true)) {
|
||||||
|
|
|
@ -87,23 +87,25 @@ public class DeleteTableHandler extends TableEventHandler {
|
||||||
MasterFileSystem mfs = this.masterServices.getMasterFileSystem();
|
MasterFileSystem mfs = this.masterServices.getMasterFileSystem();
|
||||||
Path tempTableDir = mfs.moveTableToTemp(tableName);
|
Path tempTableDir = mfs.moveTableToTemp(tableName);
|
||||||
|
|
||||||
// 4. Update table descriptor cache
|
try {
|
||||||
this.masterServices.getTableDescriptors().remove(Bytes.toString(tableName));
|
// 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(fs, mfs.getRootDir(),
|
||||||
|
tempTableDir, new Path(tempTableDir, hri.getEncodedName()));
|
||||||
|
}
|
||||||
|
|
||||||
// 5. If entry for this table in zk, and up in AssignmentManager, remove it.
|
// 5. Delete table from FS (temp directory)
|
||||||
am.getZKTable().setDeletedTable(Bytes.toString(tableName));
|
fs.delete(tempTableDir, true);
|
||||||
|
} finally {
|
||||||
|
// 6. Update table descriptor cache
|
||||||
|
this.masterServices.getTableDescriptors().remove(Bytes.toString(tableName));
|
||||||
|
|
||||||
// 6. Delete regions from FS (temp directory)
|
// 7. If entry for this table in zk, and up in AssignmentManager, remove it.
|
||||||
FileSystem fs = mfs.getFileSystem();
|
am.getZKTable().setDeletedTable(Bytes.toString(tableName));
|
||||||
for (HRegionInfo hri: regions) {
|
|
||||||
LOG.debug("Deleting region " + hri.getRegionNameAsString() + " from FS");
|
|
||||||
HFileArchiver.archiveRegion(masterServices.getConfiguration(), fs, mfs.getRootDir(),
|
|
||||||
tempTableDir, new Path(tempTableDir, hri.getEncodedName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Delete table from FS (temp directory)
|
|
||||||
fs.delete(tempTableDir, true);
|
|
||||||
|
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
cpHost.postDeleteTableHandler(this.tableName);
|
cpHost.postDeleteTableHandler(this.tableName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4374,10 +4374,10 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete out the 'A' region
|
// delete out the 'A' region
|
||||||
HFileArchiver.archiveRegion(a.getBaseConf(), fs,
|
HFileArchiver.archiveRegion(fs,
|
||||||
FSUtils.getRootDir(a.getBaseConf()), a.getTableDir(), a.getRegionDir());
|
FSUtils.getRootDir(a.getBaseConf()), a.getTableDir(), a.getRegionDir());
|
||||||
// delete out the 'B' region
|
// delete out the 'B' region
|
||||||
HFileArchiver.archiveRegion(a.getBaseConf(), fs,
|
HFileArchiver.archiveRegion(fs,
|
||||||
FSUtils.getRootDir(b.getBaseConf()), b.getTableDir(), b.getRegionDir());
|
FSUtils.getRootDir(b.getBaseConf()), b.getTableDir(), b.getRegionDir());
|
||||||
|
|
||||||
LOG.info("merge completed. New region is " + dstRegion);
|
LOG.info("merge completed. New region is " + dstRegion);
|
||||||
|
|
|
@ -358,7 +358,7 @@ public class TestHFileArchiving {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to archive the file
|
// Try to archive the file
|
||||||
HFileArchiver.archiveRegion(conf, fs, rootDir,
|
HFileArchiver.archiveRegion(fs, rootDir,
|
||||||
sourceRegionDir.getParent(), sourceRegionDir);
|
sourceRegionDir.getParent(), sourceRegionDir);
|
||||||
|
|
||||||
// The archiver succeded, the file is no longer in the original location
|
// The archiver succeded, the file is no longer in the original location
|
||||||
|
|
Loading…
Reference in New Issue