Package org.apache.cassandra.locator
Class LocalStrategy
- java.lang.Object
-
- org.apache.cassandra.locator.AbstractReplicationStrategy
-
- org.apache.cassandra.locator.LocalStrategy
-
public class LocalStrategy extends AbstractReplicationStrategy
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
configOptions, keyspaceName, snitch
-
-
Constructor Summary
Constructors Constructor Description LocalStrategy(java.lang.String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EndpointsForRangecalculateNaturalReplicas(Token token, TokenMetadata metadata)Calculate the natural endpoints for the given token.EndpointsForRangegetNaturalReplicas(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.ReplicationFactorgetReplicationFactor()calculate the RF based on strategy_options.voidmaybeWarnOnOptions()java.util.Collection<java.lang.String>recognizedOptions()voidvalidateOptions()-
Methods 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 Detail
-
LocalStrategy
public LocalStrategy(java.lang.String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions)
-
-
Method Detail
-
getNaturalReplicas
public EndpointsForRange 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.- Overrides:
getNaturalReplicasin classAbstractReplicationStrategy
-
calculateNaturalReplicas
public EndpointsForRange calculateNaturalReplicas(Token token, TokenMetadata metadata)
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:
AbstractReplicationStrategy.getNaturalReplicasForToken(org.apache.cassandra.dht.RingPosition)
-
getReplicationFactor
public ReplicationFactor 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
public void validateOptions() throws ConfigurationException- Specified by:
validateOptionsin classAbstractReplicationStrategy- Throws:
ConfigurationException
-
maybeWarnOnOptions
public void maybeWarnOnOptions()
- Overrides:
maybeWarnOnOptionsin classAbstractReplicationStrategy
-
recognizedOptions
public java.util.Collection<java.lang.String> recognizedOptions()
- Overrides:
recognizedOptionsin classAbstractReplicationStrategy
-
-