Search in sources :

Example 1 with GossipHelper.decommission

use of org.apache.cassandra.distributed.action.GossipHelper.decommission in project cassandra by apache.

the class HintedHandoffAddRemoveNodesTest method shouldStreamHintsDuringDecommission.

/**
 * Replaces Python dtest {@code hintedhandoff_test.py:TestHintedHandoff.test_hintedhandoff_decom()}.
 * Ignored for now as there is some in-jvm bug which needs to be fixed, otherwise the test is flaky
 * For more information see CASSANDRA-16679
 */
@Ignore
@Test
public void shouldStreamHintsDuringDecommission() throws Exception {
    try (Cluster cluster = builder().withNodes(4).withConfig(config -> config.with(NETWORK, GOSSIP, NATIVE_PROTOCOL)).start()) {
        cluster.schemaChange(withKeyspace("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}"));
        cluster.schemaChange(withKeyspace("CREATE TABLE %s.decom_hint_test (key int PRIMARY KEY, value int)"));
        cluster.get(4).shutdown().get();
        // Write data using the second node as the coordinator...
        populate(cluster, "decom_hint_test", 2, 0, 128, ConsistencyLevel.ONE);
        Long totalHints = countTotalHints(cluster);
        // ...and verify that we've accumulated hints intended for node 4, which is down.
        assertThat(totalHints).isGreaterThan(0);
        // Decomision node 1...
        assertEquals(4, endpointsKnownTo(cluster, 2));
        cluster.run(decommission(), 1);
        await().pollDelay(1, SECONDS).until(() -> endpointsKnownTo(cluster, 2) == 3);
        // ...and verify that all data still exists on either node 2 or 3.
        verify(cluster, "decom_hint_test", 2, 0, 128, ConsistencyLevel.ONE);
        // Start node 4 back up and verify that all hints were delivered.
        cluster.get(4).startup();
        await().atMost(30, SECONDS).pollDelay(3, SECONDS).until(() -> count(cluster, "decom_hint_test", 4).equals(totalHints));
        // Now decommission both nodes 2 and 3...
        cluster.run(GossipHelper.decommission(true), 2);
        cluster.run(GossipHelper.decommission(true), 3);
        await().pollDelay(1, SECONDS).until(() -> endpointsKnownTo(cluster, 4) == 1);
        // ...and verify that even if we drop below the replication factor of 2, all data has been preserved.
        verify(cluster, "decom_hint_test", 4, 0, 128, ConsistencyLevel.ONE);
    }
}
Also used : StorageMetrics(org.apache.cassandra.metrics.StorageMetrics) StorageService(org.apache.cassandra.service.StorageService) Test(org.junit.Test) ConsistencyLevel(org.apache.cassandra.distributed.api.ConsistencyLevel) GossipHelper(org.apache.cassandra.distributed.action.GossipHelper) NATIVE_PROTOCOL(org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL) TimeUnit(java.util.concurrent.TimeUnit) AssertUtils.assertRows(org.apache.cassandra.distributed.shared.AssertUtils.assertRows) TokenSupplier(org.apache.cassandra.distributed.api.TokenSupplier) Ignore(org.junit.Ignore) Cluster(org.apache.cassandra.distributed.Cluster) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) Awaitility(org.awaitility.Awaitility) NETWORK(org.apache.cassandra.distributed.api.Feature.NETWORK) AssertUtils.row(org.apache.cassandra.distributed.shared.AssertUtils.row) Assert.assertEquals(org.junit.Assert.assertEquals) GossipHelper.decommission(org.apache.cassandra.distributed.action.GossipHelper.decommission) GOSSIP(org.apache.cassandra.distributed.api.Feature.GOSSIP) Cluster(org.apache.cassandra.distributed.Cluster) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TimeUnit (java.util.concurrent.TimeUnit)1 Cluster (org.apache.cassandra.distributed.Cluster)1 GossipHelper (org.apache.cassandra.distributed.action.GossipHelper)1 GossipHelper.decommission (org.apache.cassandra.distributed.action.GossipHelper.decommission)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1 GOSSIP (org.apache.cassandra.distributed.api.Feature.GOSSIP)1 NATIVE_PROTOCOL (org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL)1 NETWORK (org.apache.cassandra.distributed.api.Feature.NETWORK)1 TokenSupplier (org.apache.cassandra.distributed.api.TokenSupplier)1 AssertUtils.assertRows (org.apache.cassandra.distributed.shared.AssertUtils.assertRows)1 AssertUtils.row (org.apache.cassandra.distributed.shared.AssertUtils.row)1 NetworkTopology (org.apache.cassandra.distributed.shared.NetworkTopology)1 StorageMetrics (org.apache.cassandra.metrics.StorageMetrics)1 StorageService (org.apache.cassandra.service.StorageService)1 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)1 Awaitility (org.awaitility.Awaitility)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1