I am using Cassandra 1.2.4 on my machine (windows 7).
I have got 3 nodes in my DC1, which is on my machine. I am only using one DC (my machine). I did keep replication factor=2 and "HConsistencyLevel.ONE". However, when one of the nodes is down, and I attempt to read or write to DB, I get the error - "May not be enough replicas present to handle consistency level.".
I am under the impression that when we keep the consistency level as "ONE" and even if one node is up, the write/read should happen. But I get this error. Could someone correct me as what I was doing wrong here. I want to make the read/write happen in the event of node failure. Below is my code.
String clusterName="Test Cluster";
CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(host);
Cluster cluster = HFactory.getOrCreateCluster(clusterName,cassandraHostConfigurator);
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keySpaceName);
ConfigurableConsistencyLevel configurableConsistencyLevel = new ConfigurableConsistencyLevel();
Map<String, HConsistencyLevel> clmap = new HashMap<String, HConsistencyLevel>();
// Define CL.ONE for ColumnFamily "ktable"
if(keyspaceDef==null) // Create the keyspace and add it to the cluster if keyspace does not exist
KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(
keySpaceName, ThriftKsDef.DEF_STRATEGY_CLASS,replicationFactor, null);
Keyspace keyspace = HFactory.createKeyspace(keySpaceName, cluster, configurableConsistencyLevel);
StringSerializer ss = StringSerializer.get();
ColumnFamilyTemplate<String, String> cft = new ThriftColumnFamilyTemplate<String, String>(keyspace, columFamilyName, ss, ss);
ColumnFamilyUpdater<String, String> updater = cft.createUpdater("xkey");
UUID uid = new UUID();
updater.setValue("name", "Catherine", ss);
updater.setValue("state", "GA", ss);