HBASE-9434 hbck tries to sideline file to root dir

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1520356 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2013-09-05 16:06:17 +00:00
parent 285e028f37
commit ab61360461
1 changed files with 7 additions and 6 deletions

View File

@ -497,6 +497,7 @@ public class HBaseFsck extends Configured implements Tool {
* likely violate table integrity but will be dealt with by merging
* overlapping regions.
*/
@SuppressWarnings("deprecation")
private void adoptHdfsOrphan(HbckInfo hi) throws IOException {
Path p = hi.getHdfsRegionDir();
FileSystem fs = p.getFileSystem(getConf());
@ -666,18 +667,18 @@ public class HBaseFsck extends Configured implements Tool {
String pathStr = path.toString();
// A reference file path should be like
// ${hbase.rootdir}/table_name/region_id/family_name/referred_file.region_name
// Up 3 directories to get the table folder.
// ${hbase.rootdir}/data/namespace/table_name/region_id/family_name/referred_file.region_name
// Up 5 directories to get the root folder.
// So the file will be sidelined to a similar folder structure.
int index = pathStr.lastIndexOf(Path.SEPARATOR_CHAR);
for (int i = 0; index > 0 && i < 3; i++) {
index = pathStr.lastIndexOf(Path.SEPARATOR_CHAR, index);
for (int i = 0; index > 0 && i < 5; i++) {
index = pathStr.lastIndexOf(Path.SEPARATOR_CHAR, index - 1);
}
if (index > 0) {
Path rootDir = getSidelineDir();
Path dst = new Path(rootDir, pathStr.substring(index));
Path dst = new Path(rootDir, pathStr.substring(index + 1));
fs.mkdirs(dst.getParent());
LOG.info("Trying to sildeline reference file"
LOG.info("Trying to sildeline reference file "
+ path + " to " + dst);
setShouldRerun();