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));
}
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);
}
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));
}
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));
}
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();
}
Aggregations