Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api/src/main/java/marquez/jobs/DbRetentionJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
public class DbRetentionJob extends AbstractScheduledService implements Managed {
private static final Duration NO_DELAY = Duration.ofMinutes(0);

/* The retention policy frequency. */
private final int frequencyMins;

/* The number of rows deleted per batch. */
private final int numberOfRowsPerBatch;

Expand All @@ -42,10 +45,11 @@ public class DbRetentionJob extends AbstractScheduledService implements Managed
*/
public DbRetentionJob(
@NonNull final Jdbi jdbi, @NonNull final DbRetentionConfig dbRetentionConfig) {
this.frequencyMins = dbRetentionConfig.getFrequencyMins();
this.numberOfRowsPerBatch = dbRetentionConfig.getNumberOfRowsPerBatch();
this.retentionDays = dbRetentionConfig.getRetentionDays();

// Open connection.
// Connection to database retention policy will be applied.
this.jdbi = jdbi;

// Define fixed schedule with no delay.
Expand All @@ -61,8 +65,12 @@ protected Scheduler scheduler() {

@Override
public void start() throws Exception {
log.info("Starting db retention job...");
startAsync().awaitRunning();
log.info(
"Started db retention job with retention policy of '{}' days, "
+ "scheduled to be applied every '{}' mins.",
retentionDays,
frequencyMins);
}

@Override
Expand Down