Skip to content

Commit

Permalink
Make backup grooming function in the local bootstrap case. (#1071) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattl-netflix committed Sep 24, 2023
1 parent a21dfbe commit a763465
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Expand Up @@ -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.*;
Expand Down Expand Up @@ -76,8 +77,8 @@ public BackupTTLTask(
@Named("v2") IMetaProxy metaProxy,
IFileSystemContext backupFileSystemCtx,
Provider<AbstractBackupPath> abstractBackupPathProvider,
InstanceState instanceState,
TokenRetriever tokenRetriever)
TokenRetriever tokenRetriever,
InstanceState instanceState)
throws Exception {
super(configuration);
this.backupRestoreConfig = backupRestoreConfig;
Expand All @@ -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
Expand Down
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a763465

Please sign in to comment.