org.apache.cassandra.locator
Class DatacenterShardStrategy
java.lang.Object
org.apache.cassandra.locator.AbstractReplicationStrategy
org.apache.cassandra.locator.DatacenterShardStrategy
public class DatacenterShardStrategy
- extends AbstractReplicationStrategy
This Replication Strategy takes a property file that gives the intended
replication factor in each datacenter. The sum total of the datacenter
replication factor values should be equal to the keyspace replication
factor.
So for example, if the keyspace replication factor is 6, the
datacenter replication factors could be 3, 2, and 1 - so 3 replicas in
one datacenter, 2 in another, and 1 in another - totalling 6.
This class also caches the Endpoints and invalidates the cache if there is a
change in the number of tokens.
Methods inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy |
clearCachedEndpoints, createReplicationStrategy, createReplicationStrategy, getAddressRanges, getAddressRanges, getHintedEndpoints, getNaturalEndpoints, getPendingAddressRanges, getRangeAddresses, invalidateCachedSnitchValues, invalidateCachedTokenEndpointValues |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DatacenterShardStrategy
public DatacenterShardStrategy(java.lang.String table,
TokenMetadata tokenMetadata,
IEndpointSnitch snitch,
java.util.Map<java.lang.String,java.lang.String> configOptions)
throws ConfigurationException
- Throws:
ConfigurationException
calculateNaturalEndpoints
public java.util.Set<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken,
TokenMetadata tokenMetadata)
- Description copied from class:
AbstractReplicationStrategy
- calculate the natural endpoints for the given token
- Specified by:
calculateNaturalEndpoints
in class AbstractReplicationStrategy
- Parameters:
searchToken
- the token the natural endpoints are requested for
- Returns:
- a copy of the natural endpoints for the given token
- See Also:
AbstractReplicationStrategy.getNaturalEndpoints(org.apache.cassandra.dht.Token)
getReplicationFactor
public int getReplicationFactor()
getReplicationFactor
public int getReplicationFactor(java.lang.String dc)
getDatacenters
public java.util.Set<java.lang.String> getDatacenters()
getWriteResponseHandler
public AbstractWriteResponseHandler getWriteResponseHandler(java.util.Collection<java.net.InetAddress> writeEndpoints,
com.google.common.collect.Multimap<java.net.InetAddress,java.net.InetAddress> hintedEndpoints,
ConsistencyLevel consistency_level)
- This method will generate the QRH object and returns. If the Consistency
level is DCQUORUM then it will return a DCQRH with a map of local rep
factor alone. If the consistency level is DCQUORUMSYNC then it will
return a DCQRH with a map of all the DC rep factor.
- Overrides:
getWriteResponseHandler
in class AbstractReplicationStrategy
getQuorumResponseHandler
public QuorumResponseHandler getQuorumResponseHandler(IResponseResolver responseResolver,
ConsistencyLevel consistencyLevel)
- This method will generate the WRH object and returns. If the Consistency
level is DCQUORUM/DCQUORUMSYNC then it will return a DCQRH.
- Overrides:
getQuorumResponseHandler
in class AbstractReplicationStrategy
Copyright © 2010 The Apache Software Foundation