Search in sources :

Example 16 with SimpleQueryResult

use of org.apache.cassandra.distributed.api.SimpleQueryResult in project cassandra by apache.

the class ClientNetworkStopStartTest method stopStartNative.

/**
 * @see <a href="https://issues.apache.org/jira/browse/CASSANDRA-16127">CASSANDRA-16127</a>
 */
@Test
public void stopStartNative() throws IOException {
    // TODO why does trunk need GOSSIP for native to work but no other branch does?
    try (Cluster cluster = init(Cluster.build(1).withConfig(c -> c.with(Feature.GOSSIP, Feature.NATIVE_PROTOCOL)).start())) {
        IInvokableInstance node = cluster.get(1);
        assertTransportStatus(node, "binary", true);
        node.nodetoolResult("disablebinary").asserts().success();
        assertTransportStatus(node, "binary", false);
        node.nodetoolResult("enablebinary").asserts().success();
        assertTransportStatus(node, "binary", true);
        // now use it to make sure it still works!
        cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, value int, PRIMARY KEY (pk))");
        try (com.datastax.driver.core.Cluster client = com.datastax.driver.core.Cluster.builder().addContactPoints(node.broadcastAddress().getAddress()).build();
            Session session = client.connect()) {
            session.execute("INSERT INTO " + KEYSPACE + ".tbl (pk, value) VALUES (?, ?)", 0, 0);
        }
        SimpleQueryResult qr = cluster.coordinator(1).executeWithResult("SELECT * FROM " + KEYSPACE + ".tbl", ConsistencyLevel.ALL);
        AssertUtils.assertRows(qr, QueryResults.builder().row(0, 0).build());
    }
}
Also used : IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) SimpleQueryResult(org.apache.cassandra.distributed.api.SimpleQueryResult) Cluster(org.apache.cassandra.distributed.Cluster) Session(com.datastax.driver.core.Session) Test(org.junit.Test)

Aggregations

SimpleQueryResult (org.apache.cassandra.distributed.api.SimpleQueryResult)16 Cluster (org.apache.cassandra.distributed.Cluster)13 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)13 Test (org.junit.Test)13 IOException (java.io.IOException)12 List (java.util.List)12 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)12 Feature (org.apache.cassandra.distributed.api.Feature)12 TestBaseImpl (org.apache.cassandra.distributed.test.TestBaseImpl)12 Arrays (java.util.Arrays)10 Assertions (org.assertj.core.api.Assertions)8 TokenSupplier (org.apache.cassandra.distributed.api.TokenSupplier)6 ClusterUtils.assertRingIs (org.apache.cassandra.distributed.shared.ClusterUtils.assertRingIs)6 ClusterUtils.awaitRingHealthy (org.apache.cassandra.distributed.shared.ClusterUtils.awaitRingHealthy)6 ClusterUtils.awaitRingJoin (org.apache.cassandra.distributed.shared.ClusterUtils.awaitRingJoin)6 ClusterUtils.replaceHostAndStart (org.apache.cassandra.distributed.shared.ClusterUtils.replaceHostAndStart)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 ResultSet (com.datastax.driver.core.ResultSet)5 SimpleStatement (com.datastax.driver.core.SimpleStatement)5