Package org.apache.cassandra.locator
Class SimpleStrategy
- java.lang.Object
-
- org.apache.cassandra.locator.AbstractReplicationStrategy
-
- org.apache.cassandra.locator.SimpleStrategy
-
public class SimpleStrategy extends AbstractReplicationStrategy
This class returns the nodes responsible for a given key but does not respect rack awareness. Basically returns the RF nodes that lie right next to each other on the ring.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REPLICATION_FACTOR
-
Fields inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
configOptions, keyspaceName, snitch
-
-
Constructor Summary
Constructors Constructor Description SimpleStrategy(java.lang.String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EndpointsForRange
calculateNaturalReplicas(Token token, TokenMetadata metadata)
Calculate the natural endpoints for the given token.ReplicationFactor
getReplicationFactor()
calculate the RF based on strategy_options.void
maybeWarnOnOptions(ClientState state)
protected static void
prepareOptions(java.util.Map<java.lang.String,java.lang.String> options, java.util.Map<java.lang.String,java.lang.String> previousOptions)
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, getNaturalReplicas, getNaturalReplicasForToken, getPendingAddressRanges, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, getWriteResponseHandler, hasSameSettings, hasTransientReplicas, isTokenInLocalNaturalOrPendingRange, maybeWarnOnOptions, prepareReplicationStrategyOptions, validateExpectedOptions, validateReplicationFactor, validateReplicationStrategy
-
-
-
-
Field Detail
-
REPLICATION_FACTOR
public static final java.lang.String REPLICATION_FACTOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SimpleStrategy
public SimpleStrategy(java.lang.String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions)
-
-
Method Detail
-
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(ClientState state)
- Overrides:
maybeWarnOnOptions
in classAbstractReplicationStrategy
-
recognizedOptions
public java.util.Collection<java.lang.String> recognizedOptions()
- Overrides:
recognizedOptions
in classAbstractReplicationStrategy
-
prepareOptions
protected static void prepareOptions(java.util.Map<java.lang.String,java.lang.String> options, java.util.Map<java.lang.String,java.lang.String> previousOptions)
-
-