org.apache.cassandra.locator
Class NetworkTopologyStrategy

java.lang.Object
  extended by org.apache.cassandra.locator.AbstractReplicationStrategy
      extended by org.apache.cassandra.locator.NetworkTopologyStrategy

public class NetworkTopologyStrategy
extends AbstractReplicationStrategy

This Replication Strategy takes a property file that gives the intended replication factor in each datacenter. The sum total of the datacenter replication factor values should be equal to the keyspace replication factor.

So for example, if the keyspace replication factor is 6, the datacenter replication factors could be 3, 2, and 1 - so 3 replicas in one datacenter, 2 in another, and 1 in another - totalling 6.

This class also caches the Endpoints and invalidates the cache if there is a change in the number of tokens.


Field Summary
 
Fields inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
configOptions, table
 
Constructor Summary
NetworkTopologyStrategy(java.lang.String table, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> configOptions)
           
 
Method Summary
 java.util.List<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken, TokenMetadata tokenMetadata)
          calculate the natural endpoints for the given token
 java.util.Set<java.lang.String> getDatacenters()
           
 int getReplicationFactor()
          calculate the RF based on strategy_options.
 int getReplicationFactor(java.lang.String dc)
           
 void validateOptions()
           
 
Methods inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
cacheEndpoint, clearEndpointCache, createReplicationStrategy, createReplicationStrategy, getAddressRanges, getAddressRanges, getCachedEndpoints, getClass, getHintedEndpoints, getNaturalEndpoints, getPendingAddressRanges, getRangeAddresses, getWriteResponseHandler, invalidateCachedTokenEndpointValues, validateReplicationFactor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkTopologyStrategy

public NetworkTopologyStrategy(java.lang.String table,
                               TokenMetadata tokenMetadata,
                               IEndpointSnitch snitch,
                               java.util.Map<java.lang.String,java.lang.String> configOptions)
                        throws ConfigurationException
Throws:
ConfigurationException
Method Detail

calculateNaturalEndpoints

public java.util.List<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken,
                                                                      TokenMetadata tokenMetadata)
Description copied from class: AbstractReplicationStrategy
calculate the natural endpoints for the given token

Specified by:
calculateNaturalEndpoints in class AbstractReplicationStrategy
Parameters:
searchToken - the token the natural endpoints are requested for
Returns:
a copy of the natural endpoints for the given token
See Also:
AbstractReplicationStrategy.getNaturalEndpoints(org.apache.cassandra.dht.Token)

getReplicationFactor

public int 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 class AbstractReplicationStrategy
Returns:
the replication factor

getReplicationFactor

public int getReplicationFactor(java.lang.String dc)

getDatacenters

public java.util.Set<java.lang.String> getDatacenters()

validateOptions

public void validateOptions()
                     throws ConfigurationException
Specified by:
validateOptions in class AbstractReplicationStrategy
Throws:
ConfigurationException


Copyright © 2011 The Apache Software Foundation