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, snitch
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.
|
java.util.Set<java.lang.String> |
getDatacenters() |
int |
getReplicationFactor()
calculate the RF based on strategy_options.
|
int |
getReplicationFactor(java.lang.String dc) |
boolean |
hasSameSettings(AbstractReplicationStrategy other) |
void |
validateOptions() |
createReplicationStrategy, getAddressRanges, getAddressRanges, getCachedEndpoints, getClass, getNaturalEndpoints, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, recognizedOptions, validateReplicationFactor, validateReplicationStrategy
public NetworkTopologyStrategy(java.lang.String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions) throws ConfigurationException
ConfigurationException
public java.util.List<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken, TokenMetadata tokenMetadata)
calculateNaturalEndpoints
in class AbstractReplicationStrategy
searchToken
- the token the natural endpoints are requested forAbstractReplicationStrategy.getNaturalEndpoints(org.apache.cassandra.dht.RingPosition)
public int getReplicationFactor()
AbstractReplicationStrategy
getReplicationFactor
in class AbstractReplicationStrategy
public int getReplicationFactor(java.lang.String dc)
public java.util.Set<java.lang.String> getDatacenters()
public void validateOptions() throws ConfigurationException
validateOptions
in class AbstractReplicationStrategy
ConfigurationException
public boolean hasSameSettings(AbstractReplicationStrategy other)
hasSameSettings
in class AbstractReplicationStrategy
Copyright © 2017 The Apache Software Foundation