Skip to content

Commit

Permalink
CNDB-12128 Expose to CNDB some methods around ExpirationTask (#1465)
Browse files Browse the repository at this point in the history
Expose some methods needed for
riptano/cndb#12128
  • Loading branch information
eolivelli authored Dec 16, 2024
1 parent e1945f7 commit 5c830dc
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public synchronized Collection<AbstractCompactionTask> getNextBackgroundTasks(in
return getNextBackgroundTasks(getNextCompactionAggregates(), gcBefore);
}

/// Check for fully expired sstables and return a collection of expiration tasks if found. Called by CNDB directly.
/// Check for fully expired sstables and return a collection of expiration tasks if found.
public Collection<AbstractCompactionTask> getExpirationTasks(int gcBefore)
{
long ts = System.currentTimeMillis();
Expand All @@ -344,19 +344,20 @@ public Collection<AbstractCompactionTask> getExpirationTasks(int gcBefore)
return null;
lastExpiredCheck = ts;

// Get all expired sstables, regardless of expiration status.
// This is simpler and faster than per-arena collection, and will find nothing in most calls.
var expired = CompactionController.getFullyExpiredSSTables(realm,
getSuitableSSTables(),
realm::getOverlappingLiveSSTables,
gcBefore,
controller.getIgnoreOverlapsInExpirationCheck());
var expired = getFullyExpiredSSTables(gcBefore);
if (expired.isEmpty())
return null;

if (logger.isDebugEnabled())
logger.debug("Expiration check found {} fully expired SSTables", expired.size());

return createExpirationTasks(expired);
}

/// Create expiration tasks for the given set of expired sstables.
/// Used by CNDB
public List<AbstractCompactionTask> createExpirationTasks(Set<CompactionSSTable> expired)
{
// if we found sstables to expire, split them to arenas to correctly isolate their repair status.
var tasks = new ArrayList<AbstractCompactionTask>();
try
Expand All @@ -377,6 +378,18 @@ public Collection<AbstractCompactionTask> getExpirationTasks(int gcBefore)
}
}

/// Get all expired sstables, regardless of expiration status.
/// This is simpler and faster than per-arena collection, and will find nothing in most calls.
/// Used by CNDB
public Set<CompactionSSTable> getFullyExpiredSSTables(int gcBefore)
{
return CompactionController.getFullyExpiredSSTables(realm,
getSuitableSSTables(),
realm::getOverlappingLiveSSTables,
gcBefore,
controller.getIgnoreOverlapsInExpirationCheck());
}

/// Used by CNDB where compaction aggregates come from etcd rather than the strategy
/// @return collection of `AbstractCompactionTask`, which could be either a `CompactionTask` or a `UnifiedCompactionTask`
public synchronized Collection<AbstractCompactionTask> getNextBackgroundTasks(Collection<CompactionAggregate> aggregates, int gcBefore)
Expand Down

0 comments on commit 5c830dc

Please sign in to comment.