diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporter.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporter.java index 7257a46763d..8c92e76a87b 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporter.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporter.java @@ -25,6 +25,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -40,13 +41,14 @@ public class ConsoleIndexingReporter implements IndexingReporter { private final Map metrics = new TreeMap<>(); private final List envVariablesToLog; private List indexes = List.of(); + private final List informationStrings = new ArrayList<>(); public ConsoleIndexingReporter() { this(List.of()); } /** - * @param envVariablesToLog These environment variables and their values will be included in the final report. + * @param envVariablesToLog These environment variables and their values will be included in the final report. */ public ConsoleIndexingReporter(@NotNull List envVariablesToLog) { this.envVariablesToLog = List.copyOf(envVariablesToLog); @@ -68,6 +70,11 @@ public void addMetric(String name, long value) { metrics.put(name, String.valueOf(value)); } + @Override + public void addInformation(String value) { + informationStrings.add(value); + } + public void addMetricByteSize(String name, long value) { String v = String.valueOf(value); if (value >= FileUtils.ONE_KB) { @@ -82,6 +89,7 @@ public String generateReport() { "OAK Version: " + OakVersion.getVersion() + "\n" + "Configuration:\n" + mapToString(config) + "\n" + "Environment Variables:\n" + genEnvVariables() + "\n" + + "Information:\n" + listToString(informationStrings) + "\n" + "Timings:\n" + mapToString(timings) + "\n" + "Metrics:\n" + mapToString(metrics); } @@ -95,7 +103,15 @@ private String genEnvVariables() { private String mapToString(Map map) { return map.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) .map(entry -> " " + entry.getKey() + ": " + entry.getValue()) .collect(Collectors.joining("\n")); } + + private String listToString(List map) { + return map.stream() + .sorted() + .map(entry -> " " + entry) + .collect(Collectors.joining("\n")); + } } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexingReporter.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexingReporter.java index 43bbeb44872..1ff91aa0443 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexingReporter.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexingReporter.java @@ -41,6 +41,10 @@ public void addTiming(String stage, String time) { public void addMetric(String name, long value) { } + @Override + public void addInformation(String value) { + } + @Override public void addMetricByteSize(String name, long value) { } @@ -59,6 +63,8 @@ public String generateReport() { void addMetric(String name, long value); + void addInformation(String value); + /** * Similar to {@link #addMetric(String, long)} but size should be logged in a human-friendly format, that is, * something like diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporterTest.java index 5371320057b..c797f9bbee8 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporterTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/ConsoleIndexingReporterTest.java @@ -27,7 +27,7 @@ public class ConsoleIndexingReporterTest { - private static char DELIM = new DecimalFormatSymbols().getDecimalSeparator(); + private static final char DELIM = new DecimalFormatSymbols().getDecimalSeparator(); @Test public void emptyReport() { @@ -38,6 +38,8 @@ public void emptyReport() { "\n" + "Environment Variables:\n" + "\n" + + "Information:\n" + + "\n" + "Timings:\n" + "\n" + "Metrics:\n"; @@ -59,6 +61,9 @@ public void fullReport() { "Environment Variables:\n" + " ENV_VAR1: \n" + " ENV_VAR2: \n" + + "Information:\n" + + " A message\n" + + " Foo Bar\n" + "Timings:\n" + " stage1: 10:23\n" + "Metrics:\n" + @@ -80,6 +85,8 @@ public void fullReport() { consoleIndexingReporter.addConfig("config1", "value1"); consoleIndexingReporter.addConfig("config2", 12); + consoleIndexingReporter.addInformation("Foo Bar"); + consoleIndexingReporter.addInformation("A message"); consoleIndexingReporter.addTiming("stage1", "10:23"); @@ -97,7 +104,7 @@ private String replaceDate(String report) { } private String replaceVariable(String report, String varName) { - return report.replaceAll(" " + varName + ": .*", " " + varName + ": "); + return report.replaceAll(" {2}" + varName + ": .*", " " + varName + ": "); } } \ No newline at end of file diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/pipelined/MongoRegexPathFilterFactory.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/pipelined/MongoRegexPathFilterFactory.java index b7a86ec5806..65926de3d94 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/pipelined/MongoRegexPathFilterFactory.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/pipelined/MongoRegexPathFilterFactory.java @@ -55,6 +55,10 @@ public String toString() { '}'; } + public String prettyPrint() { + return "{included=" + included + ", excluded=" + excluded + "}"; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -136,7 +140,7 @@ public MongoFilterPaths buildMongoFilter(List pathFilters, List submitDownloadTask(ExecutorService executor, DownloadTask down private MongoFilterPaths getPathsForRegexFiltering() { if (!regexPathFiltering) { LOG.info("Regex path filtering disabled."); + reporter.addInformation("Mongo regex filter paths: " + MongoFilterPaths.DOWNLOAD_ALL.prettyPrint()); return MongoFilterPaths.DOWNLOAD_ALL; } else { LOG.info("Computing included/excluded paths for Mongo regex path filtering. PathFilters: {}", @@ -493,6 +494,7 @@ private MongoFilterPaths getPathsForRegexFiltering() { ); MongoFilterPaths mongoFilterPaths = this.regexPathFilterFactory.buildMongoFilter(pathFilters, customExcludedPaths); LOG.info("Paths used for regex filtering on Mongo: {}", mongoFilterPaths); + reporter.addInformation("Mongo regex filter paths: " + mongoFilterPaths.prettyPrint()); return mongoFilterPaths; } }