From 1b03a0440ad6e2419572813ef495da2e854218bf Mon Sep 17 00:00:00 2001 From: Patrick White Date: Thu, 9 Oct 2014 12:41:35 -0700 Subject: [PATCH] Add counters for skipped files --- .../java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java index ca721e5..3e01118 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java @@ -112,7 +112,8 @@ public class ExportSnapshot extends Configured implements Tool { private static final String INPUT_FOLDER_PREFIX = "export-files."; // Export Map-Reduce Counters, to keep track of the progress - public enum Counter { MISSING_FILES, COPY_FAILED, BYTES_EXPECTED, BYTES_COPIED, FILES_COPIED }; + public enum Counter { MISSING_FILES, FILES_COPIED, FILES_SKIPPED, COPY_FAILED, + BYTES_EXPECTED, BYTES_SKIPPED, BYTES_COPIED }; private static class ExportMapper extends Mapper { @@ -168,6 +169,10 @@ public class ExportSnapshot extends Configured implements Tool { int defaultBlockSize = Math.max((int) outputFs.getDefaultBlockSize(), BUFFER_SIZE); bufferSize = conf.getInt(CONF_BUFFER_SIZE, defaultBlockSize); LOG.info("Using bufferSize=" + StringUtils.humanReadableInt(bufferSize)); + + for (Counter c : Counter.values()) { + context.getCounter(c).increment(0); + } } byte[] copyBytes(BytesWritable bw) { @@ -247,6 +252,8 @@ public class ExportSnapshot extends Configured implements Tool { FileStatus outputStat = outputFs.getFileStatus(outputPath); if (outputStat != null && sameFile(inputStat, outputStat)) { LOG.info("Skip copy " + inputStat.getPath() + " to " + outputPath + ", same file."); + context.getCounter(Counter.FILES_SKIPPED).increment(1); + context.getCounter(Counter.BYTES_SKIPPED).increment(inputStat.getLen()); return; } } -- 1.9.3 (Apple Git-50)