Cassandra has the concept of “custom consistency,” which in part means that you can control the setting of the level of consistency for read / write operations.
You can read a little more in the documents explaining the levels of consistency and how to install them in the cqlsh shell .
To learn more, I suggest experimenting with cqlsh on a single-node Cassandra. For example, we can create a key space with a replication factor of 2 and load some data into it:
cqlsh> create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor':2};
cqlsh> create table test.keys (key int primary key, val int);
cqlsh> insert into test.keys (key, val) values (1, 1);
cqlsh> select * from test.keys;
key | val
-----+-----
1 | 1
, - , 1 node . , :
cqlsh> CONSISTENCY ALL;
Consistency level set to ALL.
cqlsh> insert into test.keys (key, val) values (2, 2);
Traceback (most recent call last):
File "resources/cassandra/bin/cqlsh.py", line 1324, in perform_simple_statement
result = future.result()
File "resources/cassandra/bin/../lib/cassandra-driver.zip/cassandra-driver/cassandra/cluster.py", line 3133, in result
raise self._final_exception
Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level ALL" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'ALL'}
cqlsh> select * from test.keys;
Traceback (most recent call last):
File "resources/cassandra/bin/cqlsh.py", line 1324, in perform_simple_statement
result = future.result()
File "resources/cassandra/bin/../lib/cassandra-driver.zip/cassandra-driver/cassandra/cluster.py", line 3133, in result
raise self._final_exception
Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level ALL" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'ALL'}
, , 2- node . , , .
cqlsh, Java, , .