use of org.apache.cassandra.io.sstable.format.SSTableReader in project cassandra by apache.
the class PendingRepairManagerTest method estimateRemainingFinishedRepairTasks.
@Test
public void estimateRemainingFinishedRepairTasks() {
PendingRepairManager prm = csm.getPendingRepairManagers().get(0);
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID);
prm.addSSTable(sstable);
Assert.assertNotNull(prm.get(repairID));
Assert.assertNotNull(prm.get(repairID));
LocalSessionAccessor.finalizeUnsafe(repairID);
Assert.assertEquals(0, prm.getEstimatedRemainingTasks());
Assert.assertEquals(1, prm.getNumPendingRepairFinishedTasks());
}
use of org.apache.cassandra.io.sstable.format.SSTableReader in project cassandra by apache.
the class PendingRepairManagerTest method getNextBackgroundTask.
@Test
public void getNextBackgroundTask() {
PendingRepairManager prm = csm.getPendingRepairManagers().get(0);
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID);
prm.addSSTable(sstable);
repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
sstable = makeSSTable(true);
mutateRepaired(sstable, repairID);
prm.addSSTable(sstable);
LocalSessionAccessor.finalizeUnsafe(repairID);
Assert.assertEquals(2, prm.getSessions().size());
Assert.assertNull(prm.getNextBackgroundTask(FBUtilities.nowInSeconds()));
AbstractCompactionTask compactionTask = prm.getNextRepairFinishedTask();
Assert.assertNotNull(compactionTask);
Assert.assertSame(PendingRepairManager.RepairFinishedCompactionTask.class, compactionTask.getClass());
PendingRepairManager.RepairFinishedCompactionTask cleanupTask = (PendingRepairManager.RepairFinishedCompactionTask) compactionTask;
Assert.assertEquals(repairID, cleanupTask.getSessionID());
}
use of org.apache.cassandra.io.sstable.format.SSTableReader in project cassandra by apache.
the class PendingRepairManagerTest method maximalTaskNeedsCleanup.
@Test
public void maximalTaskNeedsCleanup() {
PendingRepairManager prm = csm.getPendingRepairManagers().get(0);
UUID repairID = registerSession(cfs, true, true);
LocalSessionAccessor.prepareUnsafe(repairID, COORDINATOR, PARTICIPANTS);
SSTableReader sstable = makeSSTable(true);
mutateRepaired(sstable, repairID);
prm.addSSTable(sstable);
Assert.assertNotNull(prm.get(repairID));
Assert.assertNotNull(prm.get(repairID));
LocalSessionAccessor.finalizeUnsafe(repairID);
Assert.assertEquals(1, prm.getMaximalTasks(FBUtilities.nowInSeconds(), false).size());
}
use of org.apache.cassandra.io.sstable.format.SSTableReader in project cassandra by apache.
the class PendingRepairManagerTest method mixedPendingSessionsTest.
@Test
public void mixedPendingSessionsTest() {
PendingRepairManager prm = csm.getPendingRepairManagers().get(0);
UUID repairId = registerSession(cfs, true, true);
UUID repairId2 = registerSession(cfs, true, true);
SSTableReader sstable = makeSSTable(true);
SSTableReader sstable2 = makeSSTable(true);
mutateRepaired(sstable, repairId);
mutateRepaired(sstable2, repairId2);
prm.addSSTable(sstable);
prm.addSSTable(sstable2);
List<AbstractCompactionTask> tasks = csm.getUserDefinedTasks(Lists.newArrayList(sstable, sstable2), 100);
Assert.assertEquals(2, tasks.size());
}
use of org.apache.cassandra.io.sstable.format.SSTableReader in project cassandra by apache.
the class SizeTieredCompactionStrategyTest method testPrepBucket.
@Test
public void testPrepBucket() throws Exception {
String ksname = KEYSPACE1;
String cfname = "Standard1";
Keyspace keyspace = Keyspace.open(ksname);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
cfs.truncateBlocking();
cfs.disableAutoCompaction();
ByteBuffer value = ByteBuffer.wrap(new byte[100]);
// create 3 sstables
int numSSTables = 3;
for (int r = 0; r < numSSTables; r++) {
String key = String.valueOf(r);
new RowUpdateBuilder(cfs.metadata(), 0, key).clustering("column").add("val", value).build().applyUnsafe();
cfs.forceBlockingFlush();
}
cfs.forceBlockingFlush();
List<SSTableReader> sstrs = new ArrayList<>(cfs.getLiveSSTables());
Pair<List<SSTableReader>, Double> bucket;
List<SSTableReader> interestingBucket = mostInterestingBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32);
assertTrue("nothing should be returned when all buckets are below the min threshold", interestingBucket.isEmpty());
sstrs.get(0).overrideReadMeter(new RestorableMeter(100.0, 100.0));
sstrs.get(1).overrideReadMeter(new RestorableMeter(200.0, 200.0));
sstrs.get(2).overrideReadMeter(new RestorableMeter(300.0, 300.0));
long estimatedKeys = sstrs.get(0).estimatedKeys();
// if we have more than the max threshold, the coldest should be dropped
bucket = trimToThresholdWithHotness(sstrs, 2);
assertEquals("one bucket should have been dropped", 2, bucket.left.size());
double expectedBucketHotness = (200.0 + 300.0) / estimatedKeys;
assertEquals(String.format("bucket hotness (%f) should be close to %f", bucket.right, expectedBucketHotness), expectedBucketHotness, bucket.right, 1.0);
}
Aggregations