Skip to content

Commit 76eb25b

Browse files
committed
ice: Moved logic of reading config value of snapshot expiration days to constructor.
1 parent 590b636 commit 76eb25b

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

examples/scratch/.ice-rest-catalog.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ s3.access-key-id: "miniouser"
55
s3.secret-access-key: "miniopassword"
66
ice.s3.region: minio
77
ice.token: foo
8+
ice.maintenance.snapshot.expiration.days: 20

ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/maintenance/MaintenanceScheduler.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ public class MaintenanceScheduler {
2929
private final Object taskLock = new Object();
3030

3131
private ScheduledFuture<?> currentTask;
32-
private volatile int expirationDays;
33-
private final String configuredDays;
32+
private final Integer snapshotExpirationDays;
3433

3534
public MaintenanceScheduler(
3635
Catalog catalog, Map<String, String> config, String maintenanceInterval) {
3736
this.catalog = catalog;
3837
this.executor = new ScheduledThreadPoolExecutor(1);
3938
((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true);
4039
this.schedule = Schedule.parse(maintenanceInterval);
41-
this.expirationDays = DEFAULT_EXPIRATION_DAYS;
42-
this.configuredDays = config.get(Config.OPTION_SNAPSHOT_EXPIRATION_DAYS);
40+
if (config.containsKey(Config.OPTION_SNAPSHOT_EXPIRATION_DAYS)) {
41+
this.snapshotExpirationDays =
42+
Integer.parseInt(config.get(Config.OPTION_SNAPSHOT_EXPIRATION_DAYS));
43+
} else {
44+
this.snapshotExpirationDays = DEFAULT_EXPIRATION_DAYS;
45+
}
4346
}
4447

4548
public void startScheduledMaintenance() {
@@ -105,21 +108,8 @@ public void performMaintenance() {
105108
for (Namespace namespace : namespaces) {
106109
List<TableIdentifier> tables = catalog.listTables(namespace);
107110
for (TableIdentifier tableIdent : tables) {
108-
109-
if (configuredDays != null) {
110-
try {
111-
expirationDays = Integer.parseInt(configuredDays);
112-
logger.debug("Using configured snapshot expiration days: {}", expirationDays);
113-
} catch (NumberFormatException e) {
114-
logger.warn(
115-
"Invalid value for {}: {}. Using default of {} days",
116-
Config.OPTION_SNAPSHOT_EXPIRATION_DAYS,
117-
configuredDays,
118-
DEFAULT_EXPIRATION_DAYS);
119-
}
120-
}
121111
long olderThanMillis =
122-
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(expirationDays);
112+
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(snapshotExpirationDays);
123113
Table table = catalog.loadTable(tableIdent);
124114

125115
// Check if table has any snapshots before performing maintenance

0 commit comments

Comments
 (0)