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 EndpointsForRange
calculateNaturalReplicas(Token token, TokenMetadata metadata)
Calculate the natural endpoints for the given token.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.ReplicationFactor
getReplicationFactor()
calculate the RF based on strategy_options.void
maybeWarnOnOptions()
java.util.Collection<java.lang.String>
recognizedOptions()
void
validateOptions()
-
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, 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:
getNaturalReplicas
in classAbstractReplicationStrategy
-
calculateNaturalReplicas
public EndpointsForRange calculateNaturalReplicas(Token token, TokenMetadata metadata)
Description copied from class:AbstractReplicationStrategy
Calculate 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:
calculateNaturalReplicas
in 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:AbstractReplicationStrategy
calculate the RF based on strategy_options. When overwriting, ensure that this get() is FAST, as this is called often.- Specified by:
getReplicationFactor
in classAbstractReplicationStrategy
- Returns:
- the replication factor
-
validateOptions
public void validateOptions() throws ConfigurationException
- Specified by:
validateOptions
in classAbstractReplicationStrategy
- Throws:
ConfigurationException
-
maybeWarnOnOptions
public void maybeWarnOnOptions()
- Overrides:
maybeWarnOnOptions
in classAbstractReplicationStrategy
-
recognizedOptions
public java.util.Collection<java.lang.String> recognizedOptions()
- Overrides:
recognizedOptions
in classAbstractReplicationStrategy
-
-