public class NetworkTopologyStrategy 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.configOptions| Constructor and Description |
|---|
NetworkTopologyStrategy(java.lang.String keyspaceName,
TokenMetadata tokenMetadata,
IEndpointSnitch snitch,
java.util.Map<java.lang.String,java.lang.String> configOptions) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.net.InetAddress> |
calculateNaturalEndpoints(Token searchToken,
TokenMetadata tokenMetadata)
calculate endpoints in one pass through the tokens by tracking our progress in each DC, rack etc.
|
java.util.Set<java.lang.String> |
getDatacenters() |
int |
getReplicationFactor()
calculate the RF based on strategy_options.
|
int |
getReplicationFactor(java.lang.String dc) |
java.util.Collection<java.lang.String> |
recognizedOptions() |
void |
validateOptions() |
createReplicationStrategy, getAddressRanges, getAddressRanges, getCachedEndpoints, getClass, getNaturalEndpoints, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, validateReplicationFactor, validateReplicationStrategypublic NetworkTopologyStrategy(java.lang.String keyspaceName,
TokenMetadata tokenMetadata,
IEndpointSnitch snitch,
java.util.Map<java.lang.String,java.lang.String> configOptions)
throws ConfigurationException
ConfigurationExceptionpublic java.util.List<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken, TokenMetadata tokenMetadata)
calculateNaturalEndpoints in class AbstractReplicationStrategysearchToken - the token the natural endpoints are requested forAbstractReplicationStrategy.getNaturalEndpoints(org.apache.cassandra.dht.RingPosition)public int getReplicationFactor()
AbstractReplicationStrategygetReplicationFactor in class AbstractReplicationStrategypublic int getReplicationFactor(java.lang.String dc)
public java.util.Set<java.lang.String> getDatacenters()
public void validateOptions()
throws ConfigurationException
validateOptions in class AbstractReplicationStrategyConfigurationExceptionpublic java.util.Collection<java.lang.String> recognizedOptions()
recognizedOptions in class AbstractReplicationStrategyCopyright © 2015 The Apache Software Foundation