From 05f6b4df00a049bbf7aa8701c286779c5685f7c0 Mon Sep 17 00:00:00 2001 From: mattl-netflix <63665634+mattl-netflix@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:52:04 -0700 Subject: [PATCH] Make backup grooming function in the local bootstrap case. (#1071) (#1073) --- .../com/netflix/priam/backupv2/BackupTTLTask.java | 13 ++++++++----- .../com/netflix/priam/backupv2/BackupV2Service.java | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/backupv2/BackupTTLTask.java b/priam/src/main/java/com/netflix/priam/backupv2/BackupTTLTask.java index cdbbd4c57..467334984 100644 --- a/priam/src/main/java/com/netflix/priam/backupv2/BackupTTLTask.java +++ b/priam/src/main/java/com/netflix/priam/backupv2/BackupTTLTask.java @@ -28,6 +28,7 @@ import com.netflix.priam.utils.DateUtil; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; @@ -76,8 +77,8 @@ public BackupTTLTask( @Named("v2") IMetaProxy metaProxy, IFileSystemContext backupFileSystemCtx, Provider abstractBackupPathProvider, - InstanceState instanceState, - TokenRetriever tokenRetriever) + TokenRetriever tokenRetriever, + InstanceState instanceState) throws Exception { super(configuration); this.backupRestoreConfig = backupRestoreConfig; @@ -86,9 +87,11 @@ public BackupTTLTask( this.abstractBackupPathProvider = abstractBackupPathProvider; this.instanceState = instanceState; this.maxWaitMillis = - 1_000 - * backupRestoreConfig.getBackupTTLMonitorPeriodInSec() - / tokenRetriever.getRingPosition().getDenominator(); + configuration.isLocalBootstrapEnabled() + ? Math.toIntExact(Duration.ofSeconds(1).toMillis()) + : 1_000 + * backupRestoreConfig.getBackupTTLMonitorPeriodInSec() + / tokenRetriever.getRingPosition().getDenominator(); } @Override diff --git a/priam/src/main/java/com/netflix/priam/backupv2/BackupV2Service.java b/priam/src/main/java/com/netflix/priam/backupv2/BackupV2Service.java index b1b185f40..846574d8a 100644 --- a/priam/src/main/java/com/netflix/priam/backupv2/BackupV2Service.java +++ b/priam/src/main/java/com/netflix/priam/backupv2/BackupV2Service.java @@ -26,6 +26,7 @@ import com.netflix.priam.scheduler.TaskTimer; import com.netflix.priam.tuner.CassandraTunerService; import javax.inject.Inject; +import org.apache.commons.lang3.math.Fraction; /** * Encapsulate the backup service 2.0 - Execute all the tasks required to run backup service. @@ -76,10 +77,13 @@ public void scheduleService() throws Exception { } else { scheduler.deleteTask(BackupVerificationTask.JOBNAME); } - // Schedule the TTL service - TaskTimer timer = - BackupTTLTask.getTimer(backupRestoreConfig, tokenRetriever.getRingPosition()); + // We cannot get the ring position in a local bootstrap scenario + Fraction ringPosition = + configuration.isLocalBootstrapEnabled() + ? Fraction.ONE_HALF + : tokenRetriever.getRingPosition(); + TaskTimer timer = BackupTTLTask.getTimer(backupRestoreConfig, ringPosition); scheduleTask(scheduler, BackupTTLTask.class, timer); // Start the Incremental backup schedule if enabled