Package org.apache.cassandra.locator
Class NetworkTopologyStrategy
java.lang.Object
org.apache.cassandra.locator.AbstractReplicationStrategy
org.apache.cassandra.locator.NetworkTopologyStrategy
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 - totaling 6.
This class also caches the Endpoints and invalidates the cache if there is a change in the number of tokens.-
Field Summary
FieldsFields inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
configOptions, keyspaceName, snitch -
Constructor Summary
ConstructorsConstructorDescriptionNetworkTopologyStrategy(String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> configOptions) -
Method Summary
Modifier and TypeMethodDescriptioncalculateNaturalReplicas(Token searchToken, TokenMetadata tokenMetadata) calculate endpoints in one pass through the tokens by tracking our progress in each DC.calculate the RF based on strategy_options.booleanvoidmaybeWarnOnOptions(ClientState state) protected static voidSupport datacenter auto-expansion for CASSANDRA-14303.protected voidvoidMethods inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
createReplicationStrategy, getAddressReplicas, getAddressReplicas, getAddressReplicas, getAddressReplicas, getCachedReplicas, getClass, getLocalReplicaFor, getNaturalReplicas, getNaturalReplicasForToken, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, getWriteResponseHandler, hasTransientReplicas, isTokenInLocalNaturalOrPendingRange, maybeWarnOnOptions, prepareReplicationStrategyOptions, validateReplicationFactor, validateReplicationStrategy
-
Field Details
-
REPLICATION_FACTOR
- See Also:
-
-
Constructor Details
-
NetworkTopologyStrategy
public NetworkTopologyStrategy(String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> configOptions) throws ConfigurationException- Throws:
ConfigurationException
-
-
Method Details
-
calculateNaturalReplicas
calculate endpoints in one pass through the tokens by tracking our progress in each DC.- Specified by:
calculateNaturalReplicasin classAbstractReplicationStrategy- Parameters:
searchToken- the token to find the natural endpoints fortokenMetadata- the token metadata used to find the searchToken, e.g. contains token to endpoint mapping information- Returns:
- a copy of the natural endpoints for the given token
- See Also:
-
getReplicationFactor
Description copied from class:AbstractReplicationStrategycalculate the RF based on strategy_options. When overwriting, ensure that this get() is FAST, as this is called often.- Specified by:
getReplicationFactorin classAbstractReplicationStrategy- Returns:
- the replication factor
-
getReplicationFactor
-
getDatacenters
-
recognizedOptions
- Overrides:
recognizedOptionsin classAbstractReplicationStrategy
-
prepareOptions
protected static void prepareOptions(Map<String, String> options, Map<String, String> previousOptions) Support datacenter auto-expansion for CASSANDRA-14303. This hook allows us to safely auto-expand the "replication_factor" options out into the known datacenters. It is called via reflection fromAbstractReplicationStrategy.prepareReplicationStrategyOptions(Class, Map, Map).- Parameters:
options- The proposed strategy options that will be potentially mutated. If empty, replication_factor will be added either from previousOptions if one exists, or from default_keyspace_rf configuration.previousOptions- Any previous strategy options in the case of an ALTER statement
-
validateExpectedOptions
- Overrides:
validateExpectedOptionsin classAbstractReplicationStrategy- Throws:
ConfigurationException
-
validateOptions
- Specified by:
validateOptionsin classAbstractReplicationStrategy- Throws:
ConfigurationException
-
maybeWarnOnOptions
- Overrides:
maybeWarnOnOptionsin classAbstractReplicationStrategy
-
hasSameSettings
- Overrides:
hasSameSettingsin classAbstractReplicationStrategy
-