org.apache.cassandra.locator

## Class AbstractReplicationStrategy

- java.lang.Object
- - org.apache.cassandra.locator.AbstractReplicationStrategy

Direct Known Subclasses:
  LocalStrategy, NetworkTopologyStrategy, OldNetworkTopologyStrategy, SimpleStrategy

    public abstract class AbstractReplicationStrategy
    extends java.lang.Object

A abstract parent for all replication strategies.

### Field Summary

Fields
`java.util.Map<java.lang.String,java.lang.String>` `configOptions`
`IEndpointSnitch` `snitch`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`abstract java.util.List<java.net.InetAddress>` `calculateNaturalEndpoints(Token searchToken, TokenMetadata tokenMetadata)` calculate the natural endpoints for the given token
`static AbstractReplicationStrategy` `createReplicationStrategy(java.lang.String keyspaceName, java.lang.Class<? extends AbstractReplicationStrategy> strategyClass, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> strategyOptions)`
`com.google.common.collect.Multimap<java.net.InetAddress,Range<Token>>` `getAddressRanges()`
`com.google.common.collect.Multimap<java.net.InetAddress,Range<Token>>` `getAddressRanges(TokenMetadata metadata)`
`java.util.ArrayList<java.net.InetAddress>` `getCachedEndpoints(Token t)`
`static java.lang.Class<AbstractReplicationStrategy>` `getClass(java.lang.String cls)`
`java.util.ArrayList<java.net.InetAddress>` `getNaturalEndpoints(RingPosition searchPosition)` get the (possibly cached) endpoints that should store the given Token.
`java.util.Collection<Range<Token>>` `getPendingAddressRanges(TokenMetadata metadata, java.util.Collection<Token> pendingTokens, java.net.InetAddress pendingAddress)`
`java.util.Collection<Range<Token>>` `getPendingAddressRanges(TokenMetadata metadata, Token pendingToken, java.net.InetAddress pendingAddress)`
`com.google.common.collect.Multimap<Range<Token>,java.net.InetAddress>` `getRangeAddresses(TokenMetadata metadata)`
`abstract int` `getReplicationFactor()` calculate the RF based on strategy_options.
`<T> AbstractWriteResponseHandler<T>` `getWriteResponseHandler(java.util.Collection<java.net.InetAddress> naturalEndpoints, java.util.Collection<java.net.InetAddress> pendingEndpoints, ConsistencyLevel consistency_level, java.lang.Runnable callback, WriteType writeType)`
`boolean` `hasSameSettings(AbstractReplicationStrategy other)`
`java.util.Collection<java.lang.String>` `recognizedOptions()`
`abstract void` `validateOptions()`
`protected void` `validateReplicationFactor(java.lang.String rf)`
`static void` `validateReplicationStrategy(java.lang.String keyspaceName, java.lang.Class<? extends AbstractReplicationStrategy> strategyClass, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> strategyOptions)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### configOptions

    public final java.util.Map<java.lang.String,java.lang.String> configOptions

#### snitch

    public IEndpointSnitch snitch

### Method Detail

#### getCachedEndpoints

    public java.util.ArrayList<java.net.InetAddress> getCachedEndpoints(Token t)

#### getNaturalEndpoints

    public java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(RingPosition searchPosition)

get the (possibly cached) endpoints that should store the given Token. Note that while the endpoints are conceptually a Set (no duplicates will be included), we return a List to avoid an extra allocation when sorting by proximity later

Parameters:
  `searchPosition` - the position the natural endpoints are requested for
Returns:
  a copy of the natural endpoints for the given token

#### calculateNaturalEndpoints

    public abstract java.util.List<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken,
                                                                                   TokenMetadata tokenMetadata)

calculate the natural endpoints for the given token

Parameters:
  `searchToken` - the token the natural endpoints are requested for
Returns:
  a copy of the natural endpoints for the given token
See Also:
  `getNaturalEndpoints(org.apache.cassandra.dht.RingPosition)`

#### getWriteResponseHandler

    public <T> AbstractWriteResponseHandler<T> getWriteResponseHandler(java.util.Collection<java.net.InetAddress> naturalEndpoints,
                                                                       java.util.Collection<java.net.InetAddress> pendingEndpoints,
                                                                       ConsistencyLevel consistency_level,
                                                                       java.lang.Runnable callback,
                                                                       WriteType writeType)

#### getReplicationFactor

    public abstract int getReplicationFactor()

calculate the RF based on strategy_options. When overwriting, ensure that this get() is FAST, as this is called often.

Returns:
  the replication factor

#### getAddressRanges

    public com.google.common.collect.Multimap<java.net.InetAddress,Range<Token>> getAddressRanges(TokenMetadata metadata)

#### getRangeAddresses

    public com.google.common.collect.Multimap<Range<Token>,java.net.InetAddress> getRangeAddresses(TokenMetadata metadata)

#### getAddressRanges

    public com.google.common.collect.Multimap<java.net.InetAddress,Range<Token>> getAddressRanges()

#### getPendingAddressRanges

    public java.util.Collection<Range<Token>> getPendingAddressRanges(TokenMetadata metadata,
                                                                      Token pendingToken,
                                                                      java.net.InetAddress pendingAddress)

#### getPendingAddressRanges

    public java.util.Collection<Range<Token>> getPendingAddressRanges(TokenMetadata metadata,
                                                                      java.util.Collection<Token> pendingTokens,
                                                                      java.net.InetAddress pendingAddress)

#### validateOptions

    public abstract void validateOptions()
                                  throws ConfigurationException

Throws:
  `ConfigurationException`

#### recognizedOptions

    public java.util.Collection<java.lang.String> recognizedOptions()

#### createReplicationStrategy

    public static AbstractReplicationStrategy createReplicationStrategy(java.lang.String keyspaceName,
                                                                        java.lang.Class<? extends AbstractReplicationStrategy> strategyClass,
                                                                        TokenMetadata tokenMetadata,
                                                                        IEndpointSnitch snitch,
                                                                        java.util.Map<java.lang.String,java.lang.String> strategyOptions)

#### validateReplicationStrategy

    public static void validateReplicationStrategy(java.lang.String keyspaceName,
                                                   java.lang.Class<? extends AbstractReplicationStrategy> strategyClass,
                                                   TokenMetadata tokenMetadata,
                                                   IEndpointSnitch snitch,
                                                   java.util.Map<java.lang.String,java.lang.String> strategyOptions)
                                            throws ConfigurationException

Throws:
  `ConfigurationException`

#### getClass

    public static java.lang.Class<AbstractReplicationStrategy> getClass(java.lang.String cls)
                                                                 throws ConfigurationException

Throws:
  `ConfigurationException`

#### hasSameSettings

    public boolean hasSameSettings(AbstractReplicationStrategy other)

#### validateReplicationFactor

    protected void validateReplicationFactor(java.lang.String rf)
                                      throws ConfigurationException

Throws:
  `ConfigurationException`