Reputation: 61
I am trying to test out setting consistency level using java driver. I created a test keyspace and table set at Replication Factor = 3 (for testing purposes, there is a cluster of node 1 set up). I did a insert from the java driver using CL set at ALL and then tried to query setting CL at ALL. Expected behavior would be it would complain about about not enough replicas being available but it doesnt complain at all. I tried to do using CQLSH CONSISTENCY Command and that worked perfectly fine. Is there something i am doing wrong?
Upvotes: 0
Views: 1391
Reputation: 305
Short summary: Replication factor describes how many copies of your data exist. Consistency level describes the behavior seen by the client. Perhaps there's a better way to categorize these.
Consistency levels in Cassandra can be configured to manage availability versus data accuracy.
You can configure consistency on a cluster, data center, or per individual read or write operation. Consistency among participating nodes can be set globally and also controlled on a per-operation basis.
For programming client applications, set the consistency level using an appropriate driver. For example, using the Java driver, call QueryBuilder.insertInto with setConsistencyLevel to set a per-insert consistency level.
You did nothing wrong What would have happened in your case : -
CONSISTENCY LEVEL 'ALL' say : - A write must be written to the commit log and memtable on all replica nodes in the cluster for that partition.
as you have only 1 node setup , and if you are querying locally (i.e on same machine where Cassandra is setup ) then the data is already present/persisted on your node and also writes and read are fast enough so you don't get any error .
To Best Analyze the Scenario you can go to the below Link : -
https://www.ecyrd.com/cassandracalculator/
Hope it helps.
Upvotes: 1