Search in sources :

Example 1 with SSTableListChangedNotification

use of org.apache.cassandra.notifications.SSTableListChangedNotification in project cassandra by apache.

the class CompactionStrategyManagerPendingRepairTest method sstableListChangedAddAndRemove.

@Test
public void sstableListChangedAddAndRemove() {
    UUID repairID = registerSession(cfs, true, true);
    LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
    SSTableReader sstable1 = makeSSTable(true);
    mutateRepaired(sstable1, repairID);
    SSTableReader sstable2 = makeSSTable(true);
    mutateRepaired(sstable2, repairID);
    Assert.assertFalse(repairedContains(sstable1));
    Assert.assertFalse(unrepairedContains(sstable1));
    Assert.assertFalse(repairedContains(sstable2));
    Assert.assertFalse(unrepairedContains(sstable2));
    csm.getForPendingRepair(repairID).forEach(Assert::assertNull);
    // add only
    SSTableListChangedNotification notification;
    notification = new SSTableListChangedNotification(Collections.singleton(sstable1), Collections.emptyList(), OperationType.COMPACTION);
    csm.handleNotification(notification, cfs.getTracker());
    csm.getForPendingRepair(repairID).forEach(Assert::assertNotNull);
    Assert.assertFalse(repairedContains(sstable1));
    Assert.assertFalse(unrepairedContains(sstable1));
    Assert.assertTrue(pendingContains(repairID, sstable1));
    Assert.assertFalse(repairedContains(sstable2));
    Assert.assertFalse(unrepairedContains(sstable2));
    Assert.assertFalse(pendingContains(repairID, sstable2));
    // remove and add
    notification = new SSTableListChangedNotification(Collections.singleton(sstable2), Collections.singleton(sstable1), OperationType.COMPACTION);
    csm.handleNotification(notification, cfs.getTracker());
    Assert.assertFalse(repairedContains(sstable1));
    Assert.assertFalse(unrepairedContains(sstable1));
    Assert.assertFalse(pendingContains(repairID, sstable1));
    Assert.assertFalse(repairedContains(sstable2));
    Assert.assertFalse(unrepairedContains(sstable2));
    Assert.assertTrue(pendingContains(repairID, sstable2));
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) SSTableListChangedNotification(org.apache.cassandra.notifications.SSTableListChangedNotification) Assert(org.junit.Assert) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with SSTableListChangedNotification

use of org.apache.cassandra.notifications.SSTableListChangedNotification in project eiger by wlloyd.

the class DataTracker method notifySSTablesChanged.

public void notifySSTablesChanged(Iterable<SSTableReader> removed, Iterable<SSTableReader> added) {
    for (INotificationConsumer subscriber : subscribers) {
        INotification notification = new SSTableListChangedNotification(added, removed);
        subscriber.handleNotification(notification, this);
    }
}
Also used : INotificationConsumer(org.apache.cassandra.notifications.INotificationConsumer) SSTableListChangedNotification(org.apache.cassandra.notifications.SSTableListChangedNotification) INotification(org.apache.cassandra.notifications.INotification)

Example 3 with SSTableListChangedNotification

use of org.apache.cassandra.notifications.SSTableListChangedNotification 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);
    }
}
Also used : SSTableListChangedNotification(org.apache.cassandra.notifications.SSTableListChangedNotification) SSTableAddedNotification(org.apache.cassandra.notifications.SSTableAddedNotification)

Aggregations

SSTableListChangedNotification (org.apache.cassandra.notifications.SSTableListChangedNotification)3 UUID (java.util.UUID)1 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)1 INotification (org.apache.cassandra.notifications.INotification)1 INotificationConsumer (org.apache.cassandra.notifications.INotificationConsumer)1 SSTableAddedNotification (org.apache.cassandra.notifications.SSTableAddedNotification)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1