use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method cleanupCompactionFailed.
/**
* Tests that failed repairs result in cleanup compaction tasks
* which reclassify the sstables as unrepaired
*/
@Test
public void cleanupCompactionFailed() {
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID, false);
csm.handleNotification(new SSTableAddedNotification(Collections.singleton(sstable), null), cfs.getTracker());
LocalSessionAccessor.failUnsafe(repairID);
Assert.assertTrue(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
Assert.assertTrue(pendingContains(sstable));
Assert.assertTrue(sstable.isPendingRepair());
Assert.assertFalse(sstable.isRepaired());
// enable compaction to fetch next background task
cfs.getCompactionStrategyManager().enable();
AbstractCompactionTask compactionTask = csm.getNextBackgroundTask(FBUtilities.nowInSeconds());
Assert.assertNotNull(compactionTask);
Assert.assertSame(PendingRepairManager.RepairFinishedCompactionTask.class, compactionTask.getClass());
// run the compaction
compactionTask.execute(ActiveCompactionsTracker.NOOP);
Assert.assertFalse(repairedContains(sstable));
Assert.assertTrue(unrepairedContains(sstable));
Assert.assertFalse(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
// sstable should have pendingRepair cleared, and repairedAt set correctly
Assert.assertFalse(sstable.isPendingRepair());
Assert.assertFalse(sstable.isRepaired());
Assert.assertEquals(ActiveRepairService.UNREPAIRED_SSTABLE, sstable.getSSTableMetadata().repairedAt);
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerTest method testSSTablesAssignedToCorrectCompactionStrategy.
public void testSSTablesAssignedToCorrectCompactionStrategy(int numSSTables, int numDisks) {
// Create a mock CFS with the given number of disks
MockCFS cfs = createJBODMockCFS(numDisks);
// Check that CFS will contain numSSTables
assertEquals(numSSTables, cfs.getLiveSSTables().size());
// Creates a compaction strategy manager with an external boundary supplier
final Integer[] boundaries = computeBoundaries(numSSTables, numDisks);
MockBoundaryManager mockBoundaryManager = new MockBoundaryManager(cfs, boundaries);
logger.debug("Boundaries for {} disks is {}", numDisks, Arrays.toString(boundaries));
CompactionStrategyManager csm = new CompactionStrategyManager(cfs, mockBoundaryManager::getBoundaries, true);
// Check that SSTables are assigned to the correct Compaction Strategy
for (SSTableReader reader : cfs.getLiveSSTables()) {
verifySSTableIsAssignedToCorrectStrategy(boundaries, csm, reader);
}
for (int delta = 1; delta <= 3; delta++) {
// Update disk boundaries
Integer[] previousBoundaries = Arrays.copyOf(boundaries, boundaries.length);
updateBoundaries(mockBoundaryManager, boundaries, delta);
// Check that SSTables are still assigned to the previous boundary layout
logger.debug("Old boundaries: {} New boundaries: {}", Arrays.toString(previousBoundaries), Arrays.toString(boundaries));
for (SSTableReader reader : cfs.getLiveSSTables()) {
verifySSTableIsAssignedToCorrectStrategy(previousBoundaries, csm, reader);
}
// Reload CompactionStrategyManager so new disk boundaries will be loaded
csm.maybeReloadDiskBoundaries();
for (SSTableReader reader : cfs.getLiveSSTables()) {
// Check that SSTables are assigned to the new boundary layout
verifySSTableIsAssignedToCorrectStrategy(boundaries, csm, reader);
// Remove SSTable and check that it will be removed from the correct compaction strategy
csm.handleNotification(new SSTableDeletingNotification(reader), this);
assertFalse(((SizeTieredCompactionStrategy) csm.compactionStrategyFor(reader)).sstables.contains(reader));
// Add SSTable again and check that is correctly assigned
csm.handleNotification(new SSTableAddedNotification(Collections.singleton(reader), null), this);
verifySSTableIsAssignedToCorrectStrategy(boundaries, csm, reader);
}
}
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project eiger by wlloyd.
the class LeveledCompactionStrategy method handleNotification.
public void handleNotification(INotification notification, Object sender) {
if (notification instanceof SSTableAddedNotification) {
SSTableAddedNotification flushedNotification = (SSTableAddedNotification) notification;
manifest.add(flushedNotification.added);
} else if (notification instanceof SSTableListChangedNotification) {
SSTableListChangedNotification listChangedNotification = (SSTableListChangedNotification) notification;
manifest.promote(listChangedNotification.removed, listChangedNotification.added);
}
}
Aggregations