Search in sources :

Example 1 with Validator

use of org.apache.cassandra.repair.Validator in project cassandra by apache.

the class CompactionManagerGetSSTablesForValidationTest method legacyIncrementalRepair.

@Test
public void legacyIncrementalRepair() throws Exception {
    makeSSTables();
    registerRepair(true);
    modifySSTables();
    // get sstables for repair
    Validator validator = new Validator(desc, coordinator, FBUtilities.nowInSeconds(), false);
    Set<SSTableReader> sstables = Sets.newHashSet(CompactionManager.instance.getSSTablesToValidate(cfs, validator));
    Assert.assertNotNull(sstables);
    Assert.assertEquals(2, sstables.size());
    Assert.assertTrue(sstables.contains(pendingRepair));
    Assert.assertTrue(sstables.contains(unrepaired));
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Validator(org.apache.cassandra.repair.Validator) Test(org.junit.Test)

Example 2 with Validator

use of org.apache.cassandra.repair.Validator in project cassandra by apache.

the class SerializationsTest method testValidationCompleteWrite.

private void testValidationCompleteWrite() throws IOException {
    IPartitioner p = RandomPartitioner.instance;
    MerkleTrees mt = new MerkleTrees(p);
    // empty validation
    mt.addMerkleTree((int) Math.pow(2, 15), FULL_RANGE);
    Validator v0 = new Validator(DESC, FBUtilities.getBroadcastAddress(), -1);
    ValidationComplete c0 = new ValidationComplete(DESC, mt);
    // validation with a tree
    mt = new MerkleTrees(p);
    mt.addMerkleTree(Integer.MAX_VALUE, FULL_RANGE);
    for (int i = 0; i < 10; i++) mt.split(p.getRandomToken());
    Validator v1 = new Validator(DESC, FBUtilities.getBroadcastAddress(), -1);
    ValidationComplete c1 = new ValidationComplete(DESC, mt);
    // validation failed
    ValidationComplete c3 = new ValidationComplete(DESC);
    testRepairMessageWrite("service.ValidationComplete.bin", c0, c1, c3);
}
Also used : MerkleTrees(org.apache.cassandra.utils.MerkleTrees) Validator(org.apache.cassandra.repair.Validator) IPartitioner(org.apache.cassandra.dht.IPartitioner)

Example 3 with Validator

use of org.apache.cassandra.repair.Validator in project cassandra by apache.

the class CompactionManagerGetSSTablesForValidationTest method consistentRepair.

@Test
public void consistentRepair() throws Exception {
    makeSSTables();
    registerRepair(true);
    modifySSTables();
    // get sstables for repair
    Validator validator = new Validator(desc, coordinator, FBUtilities.nowInSeconds(), true);
    Set<SSTableReader> sstables = Sets.newHashSet(CompactionManager.instance.getSSTablesToValidate(cfs, validator));
    Assert.assertNotNull(sstables);
    Assert.assertEquals(1, sstables.size());
    Assert.assertTrue(sstables.contains(pendingRepair));
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Validator(org.apache.cassandra.repair.Validator) Test(org.junit.Test)

Example 4 with Validator

use of org.apache.cassandra.repair.Validator in project cassandra by apache.

the class CompactionManagerGetSSTablesForValidationTest method fullRepair.

@Test
public void fullRepair() throws Exception {
    makeSSTables();
    registerRepair(false);
    modifySSTables();
    // get sstables for repair
    Validator validator = new Validator(desc, coordinator, FBUtilities.nowInSeconds(), false);
    Set<SSTableReader> sstables = Sets.newHashSet(CompactionManager.instance.getSSTablesToValidate(cfs, validator));
    Assert.assertNotNull(sstables);
    Assert.assertEquals(3, sstables.size());
    Assert.assertTrue(sstables.contains(pendingRepair));
    Assert.assertTrue(sstables.contains(unrepaired));
    Assert.assertTrue(sstables.contains(repaired));
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Validator(org.apache.cassandra.repair.Validator) Test(org.junit.Test)

Example 5 with Validator

use of org.apache.cassandra.repair.Validator in project cassandra by apache.

the class LeveledCompactionStrategyTest method testValidationMultipleSSTablePerLevel.

/*
     * This exercises in particular the code of #4142
     */
@Test
public void testValidationMultipleSSTablePerLevel() throws Exception {
    byte[] b = new byte[100 * 1024];
    new Random().nextBytes(b);
    // 100 KB value, make it easy to have multiple files
    ByteBuffer value = ByteBuffer.wrap(b);
    // Enough data to have a level 1 and 2
    int rows = 40;
    int columns = 20;
    // Adds enough data to trigger multiple sstable per level
    for (int r = 0; r < rows; r++) {
        UpdateBuilder update = UpdateBuilder.create(cfs.metadata(), String.valueOf(r));
        for (int c = 0; c < columns; c++) update.newRow("column" + c).add("val", value);
        update.applyUnsafe();
        cfs.forceBlockingFlush();
    }
    waitForLeveling(cfs);
    CompactionStrategyManager strategyManager = cfs.getCompactionStrategyManager();
    // Checking we're not completely bad at math
    assertTrue(strategyManager.getSSTableCountPerLevel()[1] > 0);
    assertTrue(strategyManager.getSSTableCountPerLevel()[2] > 0);
    Range<Token> range = new Range<>(Util.token(""), Util.token(""));
    int gcBefore = keyspace.getColumnFamilyStore(CF_STANDARDDLEVELED).gcBefore(FBUtilities.nowInSeconds());
    UUID parentRepSession = UUID.randomUUID();
    ActiveRepairService.instance.registerParentRepairSession(parentRepSession, FBUtilities.getBroadcastAddress(), Arrays.asList(cfs), Arrays.asList(range), false, ActiveRepairService.UNREPAIRED_SSTABLE, true);
    RepairJobDesc desc = new RepairJobDesc(parentRepSession, UUID.randomUUID(), KEYSPACE1, CF_STANDARDDLEVELED, Arrays.asList(range));
    Validator validator = new Validator(desc, FBUtilities.getBroadcastAddress(), gcBefore);
    CompactionManager.instance.submitValidation(cfs, validator).get();
}
Also used : Random(java.util.Random) RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) UpdateBuilder(org.apache.cassandra.UpdateBuilder) Token(org.apache.cassandra.dht.Token) Range(org.apache.cassandra.dht.Range) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Validator(org.apache.cassandra.repair.Validator) Test(org.junit.Test)

Aggregations

Validator (org.apache.cassandra.repair.Validator)5 Test (org.junit.Test)4 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)3 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1 UUID (java.util.UUID)1 UpdateBuilder (org.apache.cassandra.UpdateBuilder)1 IPartitioner (org.apache.cassandra.dht.IPartitioner)1 Range (org.apache.cassandra.dht.Range)1 Token (org.apache.cassandra.dht.Token)1 RepairJobDesc (org.apache.cassandra.repair.RepairJobDesc)1 MerkleTrees (org.apache.cassandra.utils.MerkleTrees)1