Java Code Examples for com.netflix.astyanax.model.ConsistencyLevel#CL_QUORUM
The following examples show how to use
com.netflix.astyanax.model.ConsistencyLevel#CL_QUORUM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsistencyTopologyAdapter.java From emodb with Apache License 2.0 | 6 votes |
/** * Reduce the desired consistency level to be compatible with the deployed ring topology. */ public ConsistencyLevel clamp(ConsistencyLevel consistencyLevel) { // Cassandra only allows the use of LOCAL_QUORUM and EACH_QUORUM if the keyspace // placement strategy is NetworkTopologyStrategy if ((consistencyLevel == ConsistencyLevel.CL_LOCAL_QUORUM || consistencyLevel == ConsistencyLevel.CL_EACH_QUORUM) && !_networkTopology) { consistencyLevel = ConsistencyLevel.CL_QUORUM; } if (consistencyLevel == ConsistencyLevel.CL_LOCAL_ONE && !_networkTopology) { consistencyLevel = ConsistencyLevel.CL_ONE; } // we may want to write to at two or three servers to ensure the write survives the // permanent failure of any single server. but if the ring has fewer servers to // begin with (ie. it's a test ring) we must reduce the consistency level. if (consistencyLevel == ConsistencyLevel.CL_THREE && _replicationFactor < 3) { consistencyLevel = ConsistencyLevel.CL_TWO; } if (consistencyLevel == ConsistencyLevel.CL_TWO && _replicationFactor < 2) { consistencyLevel = ConsistencyLevel.CL_ONE; } return consistencyLevel; }