diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALInputFormat.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALInputFormat.java index 1815412721..f68a1601a6 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALInputFormat.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALInputFormat.java @@ -22,6 +22,7 @@ import java.io.DataOutput; import java.io.EOFException; import java.io.FileNotFoundException; import java.io.IOException; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -304,11 +305,13 @@ public class WALInputFormat extends InputFormat { private List getFiles(FileSystem fs, Path dir, long startTime, long endTime) throws IOException { + // startTime NOT respected, not implemented. List result = new ArrayList<>(); LOG.debug("Scanning " + dir.toString() + " for WAL files"); - RemoteIterator iter = fs.listLocatedStatus(dir); - if (!iter.hasNext()) return Collections.emptyList(); + if (!iter.hasNext()) { + return Collections.emptyList(); + } while (iter.hasNext()) { LocatedFileStatus file = iter.next(); if (file.isDirectory()) { @@ -321,15 +324,19 @@ public class WALInputFormat extends InputFormat { try { long fileStartTime = Long.parseLong(name.substring(idx+1)); if (fileStartTime <= endTime) { - LOG.info("Found: " + file); + LOG.info("Found {}", file); result.add(file); + } else { + LOG.debug("Skipped {}; {}/{} is older than {}/{}", file, fileStartTime, + Instant.ofEpochMilli(fileStartTime), endTime, Instant.ofEpochMilli(endTime)); } } catch (NumberFormatException x) { - idx = 0; + LOG.warn("Failed parse of start time from {}", name); + continue; } - } - if (idx == 0) { - LOG.warn("File " + name + " does not appear to be an WAL file. Skipping..."); + } else { + LOG.info("Found {}", file); + result.add(file); } } }