use of org.apache.cassandra.distributed.api.ConsistencyLevel.ALL in project cassandra by apache.
the class GossipShutdownTest method shutdownStayDownTest.
/**
* Makes sure that a node that has shutdown doesn't come back as live (without being restarted)
*/
@Test
public void shutdownStayDownTest() throws IOException, InterruptedException, ExecutionException {
ExecutorService es = Executors.newSingleThreadExecutor();
try (Cluster cluster = init(builder().withNodes(2).withConfig(config -> config.with(GOSSIP).with(NETWORK)).start())) {
cluster.schemaChange("create table " + KEYSPACE + ".tbl (id int primary key, v int)");
for (int i = 0; i < 10; i++) cluster.coordinator(1).execute("insert into " + KEYSPACE + ".tbl (id, v) values (?,?)", ALL, i, i);
Condition timeToShutdown = newOneTimeCondition();
Condition waitForShutdown = newOneTimeCondition();
AtomicBoolean signalled = new AtomicBoolean(false);
Future f = es.submit(() -> {
await(timeToShutdown);
cluster.get(1).runOnInstance(() -> {
instance.register(new EPChanges());
});
cluster.get(2).runOnInstance(() -> {
StorageService.instance.setIsShutdownUnsafeForTests(true);
instance.stop();
});
waitForShutdown.signalAll();
});
cluster.filters().outbound().from(2).to(1).verbs(GOSSIP_DIGEST_SYN.id).messagesMatching((from, to, message) -> true).drop();
cluster.filters().outbound().from(2).to(1).verbs(GOSSIP_DIGEST_ACK.id).messagesMatching((from, to, message) -> {
if (signalled.compareAndSet(false, true)) {
timeToShutdown.signalAll();
await(waitForShutdown);
return false;
}
return true;
}).drop();
// wait for gossip to exchange a few messages
sleep(10000);
f.get();
} finally {
es.shutdown();
}
}
use of org.apache.cassandra.distributed.api.ConsistencyLevel.ALL in project cassandra by apache.
the class ReadRepairTest method readRepairRTRangeMovementTest.
@Test
public void readRepairRTRangeMovementTest() throws Throwable {
ExecutorService es = Executors.newFixedThreadPool(1);
String key = "test1";
try (Cluster cluster = init(Cluster.build().withConfig(config -> config.with(Feature.GOSSIP, Feature.NETWORK).set("read_request_timeout", String.format("%dms", Integer.MAX_VALUE))).withTokenSupplier(TokenSupplier.evenlyDistributedTokens(4)).withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(4, "dc0", "rack0")).withNodes(3).start())) {
cluster.schemaChange("CREATE TABLE distributed_test_keyspace.tbl (\n" + " key text,\n" + " column1 int,\n" + " PRIMARY KEY (key, column1)\n" + ") WITH CLUSTERING ORDER BY (column1 ASC)");
cluster.forEach(i -> i.runOnInstance(() -> open(KEYSPACE).getColumnFamilyStore("tbl").disableAutoCompaction()));
for (int i = 1; i <= 2; i++) {
cluster.get(i).executeInternal("DELETE FROM distributed_test_keyspace.tbl USING TIMESTAMP 50 WHERE key=?;", key);
cluster.get(i).executeInternal("DELETE FROM distributed_test_keyspace.tbl USING TIMESTAMP 80 WHERE key=? and column1 >= ? and column1 < ?;", key, 10, 100);
cluster.get(i).executeInternal("DELETE FROM distributed_test_keyspace.tbl USING TIMESTAMP 70 WHERE key=? and column1 = ?;", key, 30);
cluster.get(i).flush(KEYSPACE);
}
cluster.get(3).executeInternal("DELETE FROM distributed_test_keyspace.tbl USING TIMESTAMP 100 WHERE key=?;", key);
cluster.get(3).flush(KEYSPACE);
// pause the read until we have bootstrapped a new node below
Condition continueRead = newOneTimeCondition();
Condition readStarted = newOneTimeCondition();
cluster.filters().outbound().from(3).to(1, 2).verbs(READ_REQ.id).messagesMatching((i, i1, iMessage) -> {
try {
readStarted.signalAll();
continueRead.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return false;
}).drop();
Future<Object[][]> read = es.submit(() -> cluster.coordinator(3).execute("SELECT * FROM distributed_test_keyspace.tbl WHERE key=? and column1 >= ? and column1 <= ?", ALL, key, 20, 40));
readStarted.await();
IInstanceConfig config = cluster.newInstanceConfig();
config.set("auto_bootstrap", true);
cluster.bootstrap(config).startup();
continueRead.signalAll();
read.get();
} finally {
es.shutdown();
}
}
Aggregations