HBASE-7723 Remove NameNode URI from ZK splitlogs (Himanshu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1452542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
larsh 2013-03-04 21:42:57 +00:00
parent 80273bd8e7
commit f28621da9b
3 changed files with 21 additions and 3 deletions

View File

@ -278,7 +278,8 @@ public class SplitLogManager extends ZooKeeperListener {
// recover-lease is done. totalSize will be under in most cases and the
// metrics that it drives will also be under-reported.
totalSize += lf.getLen();
if (enqueueSplitTask(lf.getPath().toString(), batch) == false) {
String pathToLog = FSUtils.removeRootPath(lf.getPath(), conf);
if (!enqueueSplitTask(pathToLog, batch)) {
throw new IOException("duplicate log split scheduled for " + lf.getPath());
}
}

View File

@ -108,8 +108,8 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
// interrupted or has encountered a transient error and when it has
// encountered a bad non-retry-able persistent error.
try {
if (!HLogSplitter.splitLogFile(rootdir,
fs.getFileStatus(new Path(filename)), fs, conf, p, sequenceIdChecker)) {
if (!HLogSplitter.splitLogFile(rootdir, fs.getFileStatus(new Path(rootdir, filename)),
fs, conf, p, sequenceIdChecker)) {
return Status.PREEMPTED;
}
} catch (InterruptedIOException iioe) {

View File

@ -635,6 +635,23 @@ public abstract class FSUtils {
}
}
/**
* Checks for the presence of the root path (using the provided conf object) in the given path. If
* it exists, this method removes it and returns the String representation of remaining relative path.
* @param path
* @param conf
* @return String representation of the remaining relative path
* @throws IOException
*/
public static String removeRootPath(Path path, final Configuration conf) throws IOException {
Path root = FSUtils.getRootDir(conf);
String pathStr = path.toString();
// check that the path is absolute... it has the root path in it.
if (!pathStr.startsWith(root.toString())) return pathStr;
// if not, return as it is.
return pathStr.substring(root.toString().length() + 1);// remove the "/" too.
}
/**
* If DFS, check safe mode and if so, wait until we clear it.
* @param conf configuration