diff options
author | Harald Musum <musum@yahooinc.com> | 2023-02-03 14:36:12 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-02-03 14:36:12 +0100 |
commit | 83bd7804654aff81692e322325592002a68c2949 (patch) | |
tree | 2027fbb3111c13f1ac0ebe316ea6e685ae2dfc5d /container-search/src/main/java/com/yahoo/search/logging/Spooler.java | |
parent | facd90e5c4a4f17273f8b368b78baf0a1d5a294c (diff) |
Add flag deciding if we should keep success files
flag is false by default
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/logging/Spooler.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/logging/Spooler.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/logging/Spooler.java b/container-search/src/main/java/com/yahoo/search/logging/Spooler.java index c4fe858dffc..46f7fbb0b3c 100644 --- a/container-search/src/main/java/com/yahoo/search/logging/Spooler.java +++ b/container-search/src/main/java/com/yahoo/search/logging/Spooler.java @@ -52,16 +52,22 @@ public class Spooler { private final int maxEntriesPerFile; private final Clock clock; private final AtomicReference<Instant> firstWriteTimestamp = new AtomicReference<>(); + private final boolean keepSuccessFiles; public Spooler(Clock clock) { - this(defaultSpoolPath, defaultMaxEntriesPerFile, clock); + this(clock, false); } - public Spooler(Path spoolPath, int maxEntriesPerFile, Clock clock) { + public Spooler(Clock clock, boolean keepSuccessFiles) { + this(defaultSpoolPath, defaultMaxEntriesPerFile, clock, keepSuccessFiles); + } + + public Spooler(Path spoolPath, int maxEntriesPerFile, Clock clock, boolean keepSuccessFiles) { this.spoolPath = spoolPath; this.maxEntriesPerFile = maxEntriesPerFile; this.clock = clock; this.fileNameBase.set(newFileNameBase(clock)); + this.keepSuccessFiles = keepSuccessFiles; firstWriteTimestamp.set(Instant.EPOCH); createDirs(spoolPath); } @@ -114,7 +120,7 @@ public class Spooler { throw new UncheckedIOException("Unable to process file " + f.toPath(), e); // TODO: Move to failures path } finally { - if (succcess) { + if (succcess && keepSuccessFiles) { Path file = f.toPath(); Path target = spoolPath.resolve(successesPath).resolve(f.toPath().relativize(file)).resolve(f.getName()); try { |