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 |
---|---|
EndpointsForRange |
calculateNaturalReplicas(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() |
ReplicationFactor |
getReplicationFactor()
calculate the RF based on strategy_options.
|
ReplicationFactor |
getReplicationFactor(java.lang.String dc) |
boolean |
hasSameSettings(AbstractReplicationStrategy other) |
protected static void |
prepareOptions(java.util.Map<java.lang.String,java.lang.String> options,
java.util.Map<java.lang.String,java.lang.String> previousOptions)
Support datacenter auto-expansion for CASSANDRA-14303.
|
java.util.Collection<java.lang.String> |
recognizedOptions() |
protected void |
validateExpectedOptions() |
void |
validateOptions() |
createReplicationStrategy, getAddressReplicas, getAddressReplicas, getAddressReplicas, getAddressReplicas, getCachedReplicas, getClass, getLocalReplicaFor, getNaturalReplicas, getNaturalReplicasForToken, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, getWriteResponseHandler, hasTransientReplicas, prepareReplicationStrategyOptions, 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 EndpointsForRange calculateNaturalReplicas(Token searchToken, TokenMetadata tokenMetadata)
calculateNaturalReplicas
in class AbstractReplicationStrategy
searchToken
- the token to find the natural endpoints fortokenMetadata
- the token metadata used to find the searchToken, e.g. contains token to endpoint
mapping informationAbstractReplicationStrategy.getNaturalReplicasForToken(org.apache.cassandra.dht.RingPosition)
public ReplicationFactor getReplicationFactor()
AbstractReplicationStrategy
getReplicationFactor
in class AbstractReplicationStrategy
public ReplicationFactor getReplicationFactor(java.lang.String dc)
public java.util.Set<java.lang.String> getDatacenters()
public java.util.Collection<java.lang.String> recognizedOptions()
recognizedOptions
in class AbstractReplicationStrategy
protected static void prepareOptions(java.util.Map<java.lang.String,java.lang.String> options, java.util.Map<java.lang.String,java.lang.String> previousOptions)
AbstractReplicationStrategy.prepareReplicationStrategyOptions(Class, Map, Map)
.options
- The proposed strategy options that will be potentially mutatedpreviousOptions
- Any previous strategy options in the case of an ALTER statementprotected void validateExpectedOptions() throws ConfigurationException
validateExpectedOptions
in class AbstractReplicationStrategy
ConfigurationException
public void validateOptions() throws ConfigurationException
validateOptions
in class AbstractReplicationStrategy
ConfigurationException
public boolean hasSameSettings(AbstractReplicationStrategy other)
hasSameSettings
in class AbstractReplicationStrategy
Copyright © 2009-2019 The Apache Software Foundation