org.apache.cassandra.locator
Class AbstractReplicationStrategy

java.lang.Object
  extended by org.apache.cassandra.locator.AbstractReplicationStrategy
Direct Known Subclasses:
DatacenterShardStrategy, LocalStrategy, RackAwareStrategy, RackUnawareStrategy

public abstract class AbstractReplicationStrategy
extends java.lang.Object

A abstract parent for all replication strategies.


Field Summary
 java.util.Map<java.lang.String,java.lang.String> configOptions
           
 IEndpointSnitch snitch
           
 java.lang.String table
           
 
Method Summary
abstract  java.util.Set<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken, TokenMetadata tokenMetadata)
          calculate the natural endpoints for the given token
protected  void clearCachedEndpoints()
           
static AbstractReplicationStrategy createReplicationStrategy(java.lang.String table, java.lang.Class<? extends AbstractReplicationStrategy> strategyClass, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> strategyOptions)
           
static AbstractReplicationStrategy createReplicationStrategy(java.lang.String table, java.lang.String strategyClassName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, java.util.Map<java.lang.String,java.lang.String> strategyOptions)
           
 com.google.common.collect.Multimap<java.net.InetAddress,Range> getAddressRanges()
           
 com.google.common.collect.Multimap<java.net.InetAddress,Range> getAddressRanges(TokenMetadata metadata)
           
 com.google.common.collect.Multimap<java.net.InetAddress,java.net.InetAddress> getHintedEndpoints(java.util.Collection<java.net.InetAddress> targets)
          returns Multimap of {live destination: ultimate targets}, where if target is not the same as the destination, it is a "hinted" write, and will need to be sent to the ultimate target when it becomes alive again.
 java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(Token searchToken)
          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
 java.util.Collection<Range> getPendingAddressRanges(TokenMetadata metadata, Token pendingToken, java.net.InetAddress pendingAddress)
           
 QuorumResponseHandler getQuorumResponseHandler(IResponseResolver responseResolver, ConsistencyLevel consistencyLevel)
           
 com.google.common.collect.Multimap<Range,java.net.InetAddress> getRangeAddresses(TokenMetadata metadata)
           
 AbstractWriteResponseHandler getWriteResponseHandler(java.util.Collection<java.net.InetAddress> writeEndpoints, com.google.common.collect.Multimap<java.net.InetAddress,java.net.InetAddress> hintedEndpoints, ConsistencyLevel consistencyLevel)
           
 void invalidateCachedSnitchValues()
           
 void invalidateCachedTokenEndpointValues()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

public java.lang.String table

snitch

public final IEndpointSnitch snitch

configOptions

public java.util.Map<java.lang.String,java.lang.String> configOptions
Method Detail

getNaturalEndpoints

public java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(Token searchToken)
                                                              throws java.lang.IllegalStateException
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:
searchToken - the token the natural endpoints are requested for
Returns:
a copy of the natural endpoints for the given token
Throws:
java.lang.IllegalStateException - if the number of requested replicas is greater than the number of known endpoints

calculateNaturalEndpoints

public abstract java.util.Set<java.net.InetAddress> calculateNaturalEndpoints(Token searchToken,
                                                                              TokenMetadata tokenMetadata)
                                                                       throws java.lang.IllegalStateException
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
Throws:
java.lang.IllegalStateException - if the number of requested replicas is greater than the number of known endpoints
See Also:
getNaturalEndpoints(org.apache.cassandra.dht.Token)

getWriteResponseHandler

public AbstractWriteResponseHandler getWriteResponseHandler(java.util.Collection<java.net.InetAddress> writeEndpoints,
                                                            com.google.common.collect.Multimap<java.net.InetAddress,java.net.InetAddress> hintedEndpoints,
                                                            ConsistencyLevel consistencyLevel)

getHintedEndpoints

public com.google.common.collect.Multimap<java.net.InetAddress,java.net.InetAddress> getHintedEndpoints(java.util.Collection<java.net.InetAddress> targets)
returns Multimap of {live destination: ultimate targets}, where if target is not the same as the destination, it is a "hinted" write, and will need to be sent to the ultimate target when it becomes alive again.


getAddressRanges

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

getRangeAddresses

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

getAddressRanges

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

getPendingAddressRanges

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

getQuorumResponseHandler

public QuorumResponseHandler getQuorumResponseHandler(IResponseResolver responseResolver,
                                                      ConsistencyLevel consistencyLevel)

clearCachedEndpoints

protected void clearCachedEndpoints()

invalidateCachedTokenEndpointValues

public void invalidateCachedTokenEndpointValues()

invalidateCachedSnitchValues

public void invalidateCachedSnitchValues()

createReplicationStrategy

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

createReplicationStrategy

public static AbstractReplicationStrategy createReplicationStrategy(java.lang.String table,
                                                                    java.lang.String strategyClassName,
                                                                    TokenMetadata tokenMetadata,
                                                                    IEndpointSnitch snitch,
                                                                    java.util.Map<java.lang.String,java.lang.String> strategyOptions)
                                                             throws ConfigurationException
Throws:
ConfigurationException


Copyright © 2010 The Apache Software Foundation