Search in sources :

Example 1 with SimpleClient

use of org.apache.cassandra.transport.SimpleClient in project cassandra by apache.

the class ClientWarningsTest method testLargeBatchWithProtoV4.

@Test
public void testLargeBatchWithProtoV4() throws Exception {
    createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
    try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, ProtocolVersion.V4)) {
        client.connect(false);
        QueryMessage query = new QueryMessage(createBatchStatement2(DatabaseDescriptor.getBatchSizeWarnThreshold() / 2 + 1), QueryOptions.DEFAULT);
        Message.Response resp = client.execute(query);
        assertEquals(1, resp.getWarnings().size());
        query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
        resp = client.execute(query);
        assertNull(resp.getWarnings());
    }
}
Also used : QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) Message(org.apache.cassandra.transport.Message) SimpleClient(org.apache.cassandra.transport.SimpleClient) Test(org.junit.Test)

Example 2 with SimpleClient

use of org.apache.cassandra.transport.SimpleClient in project cassandra by apache.

the class ClientWarningsTest method testLargeBatchWithProtoV2.

@Test
public void testLargeBatchWithProtoV2() throws Exception {
    createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
    try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, ProtocolVersion.V3)) {
        client.connect(false);
        QueryMessage query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
        Message.Response resp = client.execute(query);
        assertNull(resp.getWarnings());
    }
}
Also used : QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) Message(org.apache.cassandra.transport.Message) SimpleClient(org.apache.cassandra.transport.SimpleClient) Test(org.junit.Test)

Example 3 with SimpleClient

use of org.apache.cassandra.transport.SimpleClient in project cassandra by apache.

the class StressSettings method getSimpleNativeClient.

public SimpleClient getSimpleNativeClient() {
    try {
        String currentNode = node.randomNode();
        SimpleClient client = new SimpleClient(currentNode, port.nativePort);
        client.connect(false);
        client.execute("USE \"" + schema.keyspace + "\";", org.apache.cassandra.db.ConsistencyLevel.ONE);
        return client;
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
    }
}
Also used : SimpleClient(org.apache.cassandra.transport.SimpleClient)

Example 4 with SimpleClient

use of org.apache.cassandra.transport.SimpleClient in project cassandra by apache.

the class ClientWarningsTest method testTombstoneWarning.

@Test
public void testTombstoneWarning() throws Exception {
    final int iterations = 10000;
    createTable("CREATE TABLE %s (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
    try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, ProtocolVersion.V4)) {
        client.connect(false);
        for (int i = 0; i < iterations; i++) {
            QueryMessage query = new QueryMessage(String.format("INSERT INTO %s.%s (pk, ck, v) VALUES (1, %s, 1)", KEYSPACE, currentTable(), i), QueryOptions.DEFAULT);
            client.execute(query);
        }
        ColumnFamilyStore store = Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable());
        store.forceBlockingFlush();
        for (int i = 0; i < iterations; i++) {
            QueryMessage query = new QueryMessage(String.format("DELETE v FROM %s.%s WHERE pk = 1 AND ck = %s", KEYSPACE, currentTable(), i), QueryOptions.DEFAULT);
            client.execute(query);
        }
        store.forceBlockingFlush();
        {
            QueryMessage query = new QueryMessage(String.format("SELECT * FROM %s.%s WHERE pk = 1", KEYSPACE, currentTable()), QueryOptions.DEFAULT);
            Message.Response resp = client.execute(query);
            assertEquals(1, resp.getWarnings().size());
        }
    }
}
Also used : QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) SimpleClient(org.apache.cassandra.transport.SimpleClient) Test(org.junit.Test)

Example 5 with SimpleClient

use of org.apache.cassandra.transport.SimpleClient in project cassandra by apache.

the class ClientWarningsTest method testUnloggedBatchWithProtoV4.

@Test
public void testUnloggedBatchWithProtoV4() throws Exception {
    createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
    try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, ProtocolVersion.V4)) {
        client.connect(false);
        QueryMessage query = new QueryMessage(createBatchStatement2(1), QueryOptions.DEFAULT);
        Message.Response resp = client.execute(query);
        assertNull(resp.getWarnings());
        query = new QueryMessage(createBatchStatement2(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
        resp = client.execute(query);
        assertEquals(1, resp.getWarnings().size());
    }
}
Also used : QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) QueryMessage(org.apache.cassandra.transport.messages.QueryMessage) Message(org.apache.cassandra.transport.Message) SimpleClient(org.apache.cassandra.transport.SimpleClient) Test(org.junit.Test)

Aggregations

SimpleClient (org.apache.cassandra.transport.SimpleClient)5 QueryMessage (org.apache.cassandra.transport.messages.QueryMessage)4 Test (org.junit.Test)4 Message (org.apache.cassandra.transport.Message)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1