Package org.apache.cassandra.locator
Class LocalStrategy
java.lang.Object
org.apache.cassandra.locator.AbstractReplicationStrategy
org.apache.cassandra.locator.LocalStrategy
-
Field Summary
Fields inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
configOptions, keyspaceName, snitch -
Constructor Summary
ConstructorsConstructorDescriptionLocalStrategy(String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> configOptions) -
Method Summary
Modifier and TypeMethodDescriptioncalculateNaturalReplicas(Token token, TokenMetadata metadata) Calculate the natural endpoints for the given token.getNaturalReplicas(RingPosition<?> searchPosition) We need to override this even if we override calculateNaturalReplicas, because the default implementation depends on token calculations but LocalStrategy may be used before tokens are set up.calculate the RF based on strategy_options.voidvoidMethods inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
createReplicationStrategy, getAddressReplicas, getAddressReplicas, getAddressReplicas, getAddressReplicas, getCachedReplicas, getClass, getLocalReplicaFor, getNaturalReplicasForToken, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, getWriteResponseHandler, hasSameSettings, hasTransientReplicas, isTokenInLocalNaturalOrPendingRange, maybeWarnOnOptions, prepareReplicationStrategyOptions, validateExpectedOptions, validateReplicationFactor, validateReplicationStrategy
-
Constructor Details
-
LocalStrategy
public LocalStrategy(String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> configOptions)
-
-
Method Details
-
getNaturalReplicas
We need to override this even if we override calculateNaturalReplicas, because the default implementation depends on token calculations but LocalStrategy may be used before tokens are set up.- Overrides:
getNaturalReplicasin classAbstractReplicationStrategy
-
calculateNaturalReplicas
Description copied from class:AbstractReplicationStrategyCalculate the natural endpoints for the given token. Endpoints are returned in the order they occur in the ring following the searchToken, as defined by the replication strategy. Note that the order of the replicas is _implicitly relied upon_ by the definition of "primary" range inStorageService.getPrimaryRangesForEndpoint(String, InetAddressAndPort)which is in turn relied on by various components like repair and size estimate calculations.- Specified by:
calculateNaturalReplicasin classAbstractReplicationStrategy- Parameters:
token- the token to find the natural endpoints formetadata- 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
-
validateOptions
- Specified by:
validateOptionsin classAbstractReplicationStrategy- Throws:
ConfigurationException
-
maybeWarnOnOptions
public void maybeWarnOnOptions()- Overrides:
maybeWarnOnOptionsin classAbstractReplicationStrategy
-
recognizedOptions
- Overrides:
recognizedOptionsin classAbstractReplicationStrategy
-