use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.
the class VerifyTest method testOutOfRangeTokens.
@Test(expected = RuntimeException.class)
public void testOutOfRangeTokens() throws IOException {
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
fillCF(cfs, 100);
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
byte[] tk1 = new byte[1], tk2 = new byte[1];
tk1[0] = 2;
tk2[0] = 1;
tmd.updateNormalToken(new ByteOrderedPartitioner.BytesToken(tk1), InetAddressAndPort.getByName("127.0.0.1"));
tmd.updateNormalToken(new ByteOrderedPartitioner.BytesToken(tk2), InetAddressAndPort.getByName("127.0.0.2"));
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().checkOwnsTokens(true).extendedVerification(true).build())) {
verifier.verify();
} finally {
StorageService.instance.getTokenMetadata().clearUnsafe();
}
}
use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.
the class VerifyTest method testVerifyMutateRepairStatus.
@Test
public void testVerifyMutateRepairStatus() throws IOException, WriteTimeoutException {
CompactionManager.instance.disableAutoCompaction();
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CORRUPT_CF2);
cfs.truncateBlocking();
fillCF(cfs, 2);
Util.getAll(Util.cmd(cfs).build());
// make the sstable repaired:
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
sstable.descriptor.getMetadataSerializer().mutateRepairMetadata(sstable.descriptor, System.currentTimeMillis(), sstable.getPendingRepair(), sstable.isTransient());
sstable.reloadSSTableMetadata();
// break the sstable:
Long correctChecksum;
try (RandomAccessReader file = RandomAccessReader.open(new File(sstable.descriptor.filenameFor(Component.DIGEST)))) {
correctChecksum = file.readLong();
}
writeChecksum(++correctChecksum, sstable.descriptor.filenameFor(Component.DIGEST));
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().mutateRepairStatus(false).invokeDiskFailurePolicy(true).build())) {
verifier.verify();
fail("Expected a CorruptSSTableException to be thrown");
} catch (CorruptSSTableException err) {
}
assertTrue(sstable.isRepaired());
// now the repair status should be changed:
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().mutateRepairStatus(true).invokeDiskFailurePolicy(true).build())) {
verifier.verify();
fail("Expected a CorruptSSTableException to be thrown");
} catch (CorruptSSTableException err) {
}
assertFalse(sstable.isRepaired());
}
use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.
the class VerifyTest method testVerifyCorrect.
@Test
public void testVerifyCorrect() {
CompactionManager.instance.disableAutoCompaction();
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
fillCF(cfs, 2);
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().invokeDiskFailurePolicy(true).build())) {
verifier.verify();
} catch (CorruptSSTableException err) {
fail("Unexpected CorruptSSTableException");
}
}
use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.
the class VerifyTest method testVerifyLocalPartitioner.
@Test
public void testVerifyLocalPartitioner() throws UnknownHostException {
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
byte[] tk1 = new byte[1], tk2 = new byte[1];
tk1[0] = 2;
tk2[0] = 1;
tmd.updateNormalToken(new ByteOrderedPartitioner.BytesToken(tk1), InetAddressAndPort.getByName("127.0.0.1"));
tmd.updateNormalToken(new ByteOrderedPartitioner.BytesToken(tk2), InetAddressAndPort.getByName("127.0.0.2"));
// write some bogus to a localpartitioner table
Batch bogus = Batch.createLocal(UUID.randomUUID(), 0, Collections.emptyList());
BatchlogManager.store(bogus);
ColumnFamilyStore cfs = Keyspace.open("system").getColumnFamilyStore("batches");
cfs.forceBlockingFlush();
for (SSTableReader sstable : cfs.getLiveSSTables()) {
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().checkOwnsTokens(true).build())) {
verifier.verify();
}
}
}
use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.
the class VerifyTest method testMutateRepair.
@Test
public void testMutateRepair() throws IOException, ExecutionException, InterruptedException {
CompactionManager.instance.disableAutoCompaction();
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CORRUPT_CF2);
fillCF(cfs, 2);
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
sstable.descriptor.getMetadataSerializer().mutateRepairMetadata(sstable.descriptor, 1, sstable.getPendingRepair(), sstable.isTransient());
sstable.reloadSSTableMetadata();
cfs.getTracker().notifySSTableRepairedStatusChanged(Collections.singleton(sstable));
assertTrue(sstable.isRepaired());
cfs.forceMajorCompaction();
sstable = cfs.getLiveSSTables().iterator().next();
Long correctChecksum;
try (RandomAccessReader file = RandomAccessReader.open(new File(sstable.descriptor.filenameFor(Component.DIGEST)))) {
correctChecksum = file.readLong();
}
writeChecksum(++correctChecksum, sstable.descriptor.filenameFor(Component.DIGEST));
try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().invokeDiskFailurePolicy(true).mutateRepairStatus(true).build())) {
verifier.verify();
fail("should be corrupt");
} catch (CorruptSSTableException e) {
}
assertFalse(sstable.isRepaired());
}
Aggregations