Skip to content

Commit e2d0af5

Browse files
djatnieksstef1927
andauthored
STAR-1352 Port remainder of CNDB-4337 - expose all compaction picks in an aggregate, and their status (apache#472)
Co-authored-by: Stefania Alborghetti <[email protected]>
1 parent 86ff718 commit e2d0af5

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/java/org/apache/cassandra/db/compaction/CompactionAggregate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ CompactionAggregateStatistics getCommonStatistics(boolean trackHotness)
204204
numCompactingSSTables += compaction.sstables().size();
205205
}
206206

207-
if (compaction.progress() != null)
207+
if (compaction.inProgress())
208208
{
209209
read += compaction.progress().uncompressedBytesRead();
210210
written += compaction.progress().uncompressedBytesWritten();
@@ -420,7 +420,7 @@ public CompactionAggregateStatistics getStatistics()
420420
long readLevel = 0L;
421421

422422
for (CompactionPick compaction : compactions)
423-
if (!compaction.completed() && compaction.progress() != null)
423+
if (!compaction.completed() && compaction.inProgress())
424424
readLevel += compaction.progress().uncompressedBytesRead(level);
425425

426426
return new LeveledCompactionStatistics(stats, level, score, pendingCompactions, readLevel);

src/java/org/apache/cassandra/db/compaction/CompactionPick.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ public CompactionProgress progress()
198198
return progress;
199199
}
200200

201+
public boolean inProgress()
202+
{
203+
return progress != null;
204+
}
205+
201206
public boolean completed()
202207
{
203208
return completed;

src/java/org/apache/cassandra/db/compaction/UnifiedCompactionStrategy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,9 @@ CompactionAggregate.UnifiedAggregate getCompactionAggregate(Shard shard,
10071007
bipartitionSSTables(sstables, allExpiredSSTables, liveSet, expiredSet);
10081008
}
10091009

1010+
if (logger.isTraceEnabled())
1011+
logger.trace("Creating compaction aggregate with live set {}, and expired set {}", liveSet, expiredSet);
1012+
10101013
List<CompactionPick> pending = ImmutableList.of();
10111014
CompactionPick selected;
10121015
int count = liveSet.size();
@@ -1072,6 +1075,9 @@ else if (count <= fanout * controller.getFanout(index + 1))
10721075
else if (hasExpiredSSTables)
10731076
selected = selected.withExpiredSSTables(expiredSet);
10741077

1078+
if (logger.isTraceEnabled())
1079+
logger.trace("Returning compaction aggregate with selected compaction {}, and pending {}, for shard {}",
1080+
selected, pending, shard);
10751081
return CompactionAggregate.createUnified(sstables, selected, pending, shard, this);
10761082
}
10771083

test/unit/org/apache/cassandra/db/compaction/UnifiedCompactionStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void testLimitCompactionsThroughput(int maxCount, int maxThroughput)
574574
assertEquals(0, strategy.getNextBackgroundTasks(FBUtilities.nowInSeconds()).size());
575575

576576
for (CompactionPick pick : strategy.backgroundCompactions.getCompactionsInProgress())
577-
if (pick.progress() == null)
577+
if (!pick.inProgress())
578578
strategy.backgroundCompactions.onInProgress(mockProgress(strategy, pick.id()));
579579

580580
// and also when they do

0 commit comments

Comments
 (0)