From f28621da9bdabefd9e0ad9bee93308bfc2eccd41 Mon Sep 17 00:00:00 2001 From: larsh Date: Mon, 4 Mar 2013 21:42:57 +0000 Subject: [PATCH] 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 --- .../hadoop/hbase/master/SplitLogManager.java | 3 ++- .../hbase/regionserver/SplitLogWorker.java | 4 ++-- .../org/apache/hadoop/hbase/util/FSUtils.java | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java index a9bfbf2f7ad..aa0b5072f15 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java @@ -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()); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java index ff5d98b8217..4d85b52ab90 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java @@ -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) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index af154bede3d..c06e28e7847 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -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