I have following code which sets EACH_QUORUM as write and LOCAL_QUORUM as read consistency level. I am unable to set EACH_QUORUM for read. I get exception saying we cant set EACH_QUORUM for reads. So i have set LOCAL_QUORUM for Reads alone.
ConfigurableConsistencyLevel consistency = new ConfigurableConsistencyLevel();
consistency.setConsistencyLevelForCfOperation(HConsistencyLevel.EACH_QUORUM, SESSIONS, OperationType.READ);
consistency.setConsistencyLevelForCfOperation(HConsistencyLevel.EACH_QUORUM, SESSIONS, OperationType.WRITE);
consistency.setConsistencyLevelForCfOperation(HConsistencyLevel.EACH_QUORUM, SESSIONOBJECTS, OperationType.READ);
consistency.setConsistencyLevelForCfOperation(HConsistencyLevel.EACH_QUORUM, SESSIONOBJECTS, OperationType.WRITE);
Map<String, HConsistencyLevel> clmap = new HashMap<String, HConsistencyLevel>();
Map<String, HConsistencyLevel> clmapp = new HashMap<String, HConsistencyLevel>();
clmap.put(SESSIONS, HConsistencyLevel.EACH_QUORUM);
clmapp.put(SESSIONOBJECTS, HConsistencyLevel.EACH_QUORUM);
consistency.setReadCfConsistencyLevels(clmap);
consistency.setWriteCfConsistencyLevels(clmap);
consistency.setReadCfConsistencyLevels(clmapp);
consistency.setWriteCfConsistencyLevels(clmapp);
consistency.setDefaultReadConsistencyLevel(HConsistencyLevel.LOCAL_QUORUM);
consistency.setDefaultWriteConsistencyLevel(HConsistencyLevel.EACH_QUORUM);
return HFactory.createKeyspace(config.getKeySpace(), cluster, consistency, failover, credentials);
i dont see any errors in the logs as well.
One thing to note in my setup is,
i have 4 appserver running in all the 4 boxes. each appserver is configured to use the cassandra running in that box.
I have a script which does something as below
Req1 --> Appserver1 --> Grid1 in DC1
Req2 --> Appserver2 --> Grid2 in DC1
Req3 --> Appserver3 --> Grid1 in DC2
Req4 --> Appserver4 --> Grid2 in DC2
Req1 --> Appserver1 --> Grid1 in DC1
Req2 --> Appserver2 --> Grid2 in DC1
...it goes on.