Search in sources :

Example 1 with HintMessage

use of org.apache.cassandra.hints.HintMessage in project cassandra by apache.

the class MessageFiltersTest method hintSerializationTest.

@Test
public void hintSerializationTest() throws Exception {
    try (Cluster cluster = init(builder().withNodes(3).withConfig(config -> config.with(GOSSIP).with(NETWORK).set("hinted_handoff_enabled", true)).start())) {
        cluster.schemaChange(withKeyspace("CREATE TABLE %s.tbl (k int PRIMARY KEY, v int)"));
        executeWithWriteFailure(cluster, withKeyspace("INSERT INTO %s.tbl (k, v) VALUES (1,1)"), ConsistencyLevel.QUORUM, 1);
        CountDownLatch latch = new CountDownLatch(1);
        cluster.filters().verbs(Verb.HINT_REQ.id).messagesMatching((a, b, msg) -> {
            cluster.get(1).acceptsOnInstance((IIsolatedExecutor.SerializableConsumer<IMessage>) (m) -> {
                HintMessage hintMessage = (HintMessage) Instance.deserializeMessage(m).payload;
                assert hintMessage != null;
            }).accept(msg);
            latch.countDown();
            return false;
        }).drop().on();
        cluster.schemaChange(withKeyspace("DROP TABLE %s.tbl"));
        latch.await();
    }
}
Also used : HintMessage(org.apache.cassandra.hints.HintMessage) ICluster(org.apache.cassandra.distributed.api.ICluster) Cluster(org.apache.cassandra.distributed.Cluster) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 Cluster (org.apache.cassandra.distributed.Cluster)1 ICluster (org.apache.cassandra.distributed.api.ICluster)1 HintMessage (org.apache.cassandra.hints.HintMessage)1 Test (org.junit.Test)1