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());
}
}
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());
}
}
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());
}
}
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());
}
}
}
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());
}
}
Aggregations