ACCUMULO-2048 Removed unnecessary path manipulation in walog GC and added sanity check
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/bed80715 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/bed80715 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/bed80715 Branch: refs/heads/master Commit: bed80715607d6b9b74ad96e3f2a7020e8ad9f149 Parents: 66c7848 Author: Keith Turner <[email protected]> Authored: Fri Dec 20 19:56:44 2013 -0500 Committer: Keith Turner <[email protected]> Committed: Fri Dec 20 22:13:49 2013 -0500 ---------------------------------------------------------------------- .../gc/GarbageCollectWriteAheadLogs.java | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/bed80715/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java index c4c69b4..111d1e7 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java @@ -42,7 +42,6 @@ import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.conf.ServerConfiguration; import org.apache.accumulo.server.fs.VolumeManager; -import org.apache.accumulo.server.fs.VolumeManager.FileType; import org.apache.accumulo.server.security.SystemCredentials; import org.apache.accumulo.server.util.MetadataTableUtil; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; @@ -231,20 +230,19 @@ public class GarbageCollectWriteAheadLogs { InterruptedException { int count = 0; Iterator<LogEntry> iterator = MetadataTableUtil.getLogEntries(SystemCredentials.get()); + while (iterator.hasNext()) { for (String entry : iterator.next().logSet) { - String parts[] = entry.split("/", 2); - String filename = parts[1]; - Path path; - if (filename.contains(":")) - path = new Path(filename); - else - path = fs.getFullPath(FileType.WAL, filename); - - Path pathFromNN = nameToFileMap.remove(path.getName()); + String uuid = new Path(entry).getName(); + if (!isUUID(uuid)) { + // fully expect this to be a uuid, if its not then something is wrong and walog GC should not proceed! + throw new IllegalArgumentException("Expected uuid, but got " + uuid + " from " + entry); + } + + Path pathFromNN = nameToFileMap.remove(uuid); if (pathFromNN != null) { status.currentLog.inUse++; - sortedWALogs.remove(path.getName()); + sortedWALogs.remove(uuid); } count++; } @@ -258,7 +256,13 @@ public class GarbageCollectWriteAheadLogs { Set<String> servers = new HashSet<String>(); for (String walDir : ServerConstants.getWalDirs()) { Path walRoot = new Path(walDir); - FileStatus[] listing = fs.listStatus(walRoot); + FileStatus[] listing = null; + try { + listing = fs.listStatus(walRoot); + } catch (FileNotFoundException e) { + // ignore dir + } + if (listing == null) continue; for (FileStatus status : listing) {
