use of org.apache.cassandra.service.ActiveRepairService.NO_PENDING_REPAIR in project cassandra by apache.
the class AntiCompactionTest method antiCompactRanges.
private SSTableStats antiCompactRanges(ColumnFamilyStore store, RangesAtEndpoint ranges) throws IOException {
UUID sessionID = UUID.randomUUID();
Collection<SSTableReader> sstables = getUnrepairedSSTables(store);
try (LifecycleTransaction txn = store.getTracker().tryModify(sstables, OperationType.ANTICOMPACTION);
Refs<SSTableReader> refs = Refs.ref(sstables)) {
if (txn == null)
throw new IllegalStateException();
registerParentRepairSession(sessionID, ranges.ranges(), FBUtilities.nowInSeconds(), sessionID);
CompactionManager.instance.performAnticompaction(store, ranges, refs, txn, sessionID, () -> false);
}
SSTableStats stats = new SSTableStats();
stats.numLiveSSTables = store.getLiveSSTables().size();
Predicate<Token> fullContains = t -> Iterables.any(ranges.onlyFull().ranges(), r -> r.contains(t));
Predicate<Token> transContains = t -> Iterables.any(ranges.onlyTransient().ranges(), r -> r.contains(t));
for (SSTableReader sstable : store.getLiveSSTables()) {
assertFalse(sstable.isRepaired());
assertEquals(sstable.isPendingRepair() ? sessionID : NO_PENDING_REPAIR, sstable.getPendingRepair());
try (ISSTableScanner scanner = sstable.getScanner()) {
while (scanner.hasNext()) {
UnfilteredRowIterator row = scanner.next();
Token token = row.partitionKey().getToken();
if (sstable.isPendingRepair() && !sstable.isTransient()) {
assertTrue(fullContains.test(token));
assertFalse(transContains.test(token));
stats.pendingKeys++;
} else if (sstable.isPendingRepair() && sstable.isTransient()) {
assertTrue(transContains.test(token));
assertFalse(fullContains.test(token));
stats.transKeys++;
} else {
assertFalse(fullContains.test(token));
assertFalse(transContains.test(token));
stats.unrepairedKeys++;
}
}
}
}
for (SSTableReader sstable : store.getLiveSSTables()) {
assertFalse(sstable.isMarkedCompacted());
assertEquals(1, sstable.selfRef().globalCount());
}
assertEquals(0, store.getTracker().getCompacting().size());
return stats;
}
Aggregations