use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method cleanupCompactionFinalized.
/**
* Tests that finalized repairs result in cleanup compaction tasks
* which reclassify the sstables as repaired
*/
@Test
public void cleanupCompactionFinalized() throws NoSuchRepairSessionException {
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.finalizeUnsafe(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.assertTrue(repairedContains(sstable));
Assert.assertFalse(unrepairedContains(sstable));
Assert.assertFalse(pendingContains(sstable));
Assert.assertFalse(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
// sstable should have pendingRepair cleared, and repairedAt set correctly
long expectedRepairedAt = ActiveRepairService.instance.getParentRepairSession(repairID).repairedAt;
Assert.assertFalse(sstable.isPendingRepair());
Assert.assertTrue(sstable.isRepaired());
Assert.assertEquals(expectedRepairedAt, sstable.getSSTableMetadata().repairedAt);
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method finalizedSessionTransientCleanup.
@Test
public void finalizedSessionTransientCleanup() {
Assert.assertTrue(cfs.getLiveSSTables().isEmpty());
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID, true);
csm.handleNotification(new SSTableAddedNotification(Collections.singleton(sstable), null), cfs.getTracker());
LocalSessionAccessor.finalizeUnsafe(repairID);
Assert.assertFalse(hasPendingStrategiesFor(repairID));
Assert.assertTrue(hasTransientStrategiesFor(repairID));
Assert.assertTrue(transientContains(sstable));
Assert.assertFalse(pendingContains(sstable));
Assert.assertFalse(repairedContains(sstable));
Assert.assertFalse(unrepairedContains(sstable));
// 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.assertTrue(cfs.getLiveSSTables().isEmpty());
Assert.assertFalse(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method sstableDeleted.
@Test
public void sstableDeleted() {
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());
Assert.assertTrue(pendingContains(sstable));
// delete sstable
SSTableDeletingNotification notification = new SSTableDeletingNotification(sstable);
csm.handleNotification(notification, cfs.getTracker());
Assert.assertFalse(pendingContains(sstable));
Assert.assertFalse(unrepairedContains(sstable));
Assert.assertFalse(repairedContains(sstable));
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method getStrategies.
/**
* CompactionStrategyManager.getStrategies should include
* pending repair strategies when appropriate
*/
@Test
public void getStrategies() {
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
List<List<AbstractCompactionStrategy>> strategies;
strategies = csm.getStrategies();
Assert.assertEquals(3, strategies.size());
Assert.assertTrue(strategies.get(2).isEmpty());
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID, false);
csm.handleNotification(new SSTableAddedNotification(Collections.singleton(sstable), null), cfs.getTracker());
strategies = csm.getStrategies();
Assert.assertEquals(3, strategies.size());
Assert.assertFalse(strategies.get(2).isEmpty());
}
use of org.apache.cassandra.notifications.SSTableAddedNotification in project cassandra by apache.
the class CompactionStrategyManagerPendingRepairTest method sstableAdded.
/**
* Pending repair strategy should be created when we encounter a new pending id
*/
@Test
public void sstableAdded() {
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
Assert.assertTrue(Iterables.isEmpty(csm.getPendingRepairsUnsafe().allStrategies()));
SSTableReader sstable = makeSSTable(true);
Assert.assertFalse(sstable.isRepaired());
Assert.assertFalse(sstable.isPendingRepair());
mutateRepaired(sstable, repairID, false);
Assert.assertFalse(sstable.isRepaired());
Assert.assertTrue(sstable.isPendingRepair());
Assert.assertFalse(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
// add the sstable
csm.handleNotification(new SSTableAddedNotification(Collections.singleton(sstable), null), cfs.getTracker());
Assert.assertFalse(repairedContains(sstable));
Assert.assertFalse(unrepairedContains(sstable));
Assert.assertTrue(pendingContains(sstable));
Assert.assertTrue(hasPendingStrategiesFor(repairID));
Assert.assertFalse(hasTransientStrategiesFor(repairID));
}
Aggregations