Search in sources :

Example 56 with SSTableReader

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());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) UUID(java.util.UUID) Test(org.junit.Test)

Example 57 with SSTableReader

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());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) UUID(java.util.UUID) Test(org.junit.Test)

Example 58 with SSTableReader

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());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) UUID(java.util.UUID) Test(org.junit.Test)

Example 59 with SSTableReader

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());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) UUID(java.util.UUID) Test(org.junit.Test)

Example 60 with SSTableReader

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);
}
Also used : ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) RestorableMeter(org.apache.cassandra.metrics.RestorableMeter) SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) RowUpdateBuilder(org.apache.cassandra.db.RowUpdateBuilder) Keyspace(org.apache.cassandra.db.Keyspace) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)289 Test (org.junit.Test)159 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)91 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)55 Keyspace (org.apache.cassandra.db.Keyspace)49 File (java.io.File)45 UUID (java.util.UUID)28 Range (org.apache.cassandra.dht.Range)28 Directories (org.apache.cassandra.db.Directories)27 Token (org.apache.cassandra.dht.Token)24 RandomAccessFile (java.io.RandomAccessFile)22 AbstractTransactionalTest (org.apache.cassandra.utils.concurrent.AbstractTransactionalTest)20 ArrayList (java.util.ArrayList)18 ByteBuffer (java.nio.ByteBuffer)17 HashSet (java.util.HashSet)16 SchemaLoader.createKeyspace (org.apache.cassandra.SchemaLoader.createKeyspace)16 DecoratedKey (org.apache.cassandra.db.DecoratedKey)16 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)16 CompactionController (org.apache.cassandra.db.compaction.CompactionController)14 CompactionIterator (org.apache.cassandra.db.compaction.CompactionIterator)13