Allow local batchlog writes for CL.ANY

patch by jbellis; reviewed by Aleksey for CASSANDRA-5967
This commit is contained in:
Jonathan Ellis 2013-09-01 14:34:11 -05:00
parent b14273b435
commit 3380fa7baf
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,5 @@
1.2.10
* Allow local batchlog writes for CL.ANY (CASSANDRA-5967)
* Optimize name query performance in wide rows (CASSANDRA-5966)
* Upgrade metrics-core to version 2.2.0 (CASSANDRA-5947)
* Add snitch, schema version, cluster, partitioner to JMX (CASSANDRA-5881)

View File

@ -261,7 +261,7 @@ public class StorageProxy implements StorageProxyMBean
}
// write to the batchlog
Collection<InetAddress> batchlogEndpoints = getBatchlogEndpoints(localDataCenter);
Collection<InetAddress> batchlogEndpoints = getBatchlogEndpoints(localDataCenter, consistency_level);
UUID batchUUID = UUID.randomUUID();
syncWriteToBatchlog(mutations, batchlogEndpoints, batchUUID);
@ -418,7 +418,7 @@ public class StorageProxy implements StorageProxyMBean
* - choose min(2, number of qualifying candiates above)
* - allow the local node to be the only replica only if it's a single-node cluster
*/
private static Collection<InetAddress> getBatchlogEndpoints(String localDataCenter) throws UnavailableException
private static Collection<InetAddress> getBatchlogEndpoints(String localDataCenter, ConsistencyLevel consistencyLevel) throws UnavailableException
{
// will include every known node in the DC, including localhost.
TokenMetadata.Topology topology = StorageService.instance.getTokenMetadata().cloneOnlyTokenMap().getTopology();
@ -440,7 +440,12 @@ public class StorageProxy implements StorageProxyMBean
}
if (candidates.isEmpty())
{
if (consistencyLevel == ConsistencyLevel.ANY)
return Collections.singleton(FBUtilities.getBroadcastAddress());
throw new UnavailableException(ConsistencyLevel.ONE, 1, 0);
}
if (candidates.size() > 2)
{