Add expiry to SyncFileInfo
@@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.sync;
import java.net.URI;
import java.nio.file.Path;
+import java.time.Instant;
import java.util.Optional;
/**
@@ -13,11 +14,13 @@ public class SyncFileInfo {
private final Path source;
private final URI destination;
private final Compression uploadCompression;
+ private final Instant expiry;
- private SyncFileInfo(Path source, URI destination, Compression uploadCompression) {
+ private SyncFileInfo(Path source, URI destination, Compression uploadCompression, Instant expiry) {
this.source = source;
this.destination = destination;
this.uploadCompression = uploadCompression;
+ this.expiry = expiry;
}
/** Source path of the file to sync */
@@ -35,6 +38,9 @@ public class SyncFileInfo {
return uploadCompression;
}
+ /** File expiry */
+ public Optional<Instant> expiry() { return Optional.ofNullable(expiry); }
+
public static Optional<SyncFileInfo> forLogFile(URI uri, Path logFile, boolean rotatedOnly) {
String filename = logFile.getFileName().toString();
Compression compression;
@@ -55,15 +61,15 @@ public class SyncFileInfo {
if (dir == null) return Optional.empty();
return Optional.of(new SyncFileInfo(
- logFile, uri.resolve(dir + logFile.getFileName() + compression.extension), compression));
+ logFile, uri.resolve(dir + logFile.getFileName() + compression.extension), compression, null));
}
- public static Optional<SyncFileInfo> forServiceDump(URI directory, Path file) {
+ public static Optional<SyncFileInfo> forServiceDump(URI directory, Path file, Instant expiry) {
String filename = file.getFileName().toString();
Compression compression = filename.endsWith(".bin") ? Compression.ZSTD : Compression.NONE;
if (filename.startsWith(".")) return Optional.empty();
URI location = directory.resolve(filename + compression.extension);
- return Optional.of(new SyncFileInfo(file, location, compression));
+ return Optional.of(new SyncFileInfo(file, location, compression, expiry));
}
public enum Compression {
