org.apache.cassandra.locator
Class DatacenterShardStategy

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

public class DatacenterShardStategy
extends AbstractReplicationStrategy

This Stategy is little diffrent than the Rack aware Statergy. If there is replication factor is N. We will make sure that (N-1)%2 of the nodes are in other Datacenter.... For example if we have 5 nodes this stategy will make sure to make 2 copies out of 5 in other dataceneter.

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
logger_, partitioner_, replicas_, tokenMetadata_
 
Constructor Summary
DatacenterShardStategy(TokenMetadata tokenMetadata, IPartitioner<Token> partitioner, int replicas)
           
 
Method Summary
 java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(Token token, TokenMetadata metadata)
           
 WriteResponseHandler getWriteResponseHandler(int blockFor, int consistency_level)
          This method will generate the QRH object and returns.
 
Methods inherited from class org.apache.cassandra.locator.AbstractReplicationStrategy
getAddressRanges, getAddressRanges, getHintedEndpoints, getNaturalEndpoints, getPendingAddressRanges, getRangeAddresses, getWriteEndpoints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatacenterShardStategy

public DatacenterShardStategy(TokenMetadata tokenMetadata,
                              IPartitioner<Token> partitioner,
                              int replicas)
                       throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException
Method Detail

getNaturalEndpoints

public java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(Token token,
                                                                     TokenMetadata metadata)
Specified by:
getNaturalEndpoints in class AbstractReplicationStrategy

getWriteResponseHandler

public WriteResponseHandler getWriteResponseHandler(int blockFor,
                                                    int consistency_level)
This method will generate the QRH object and returns. If the Consistency level is DCQUORUM then it will return a DCQRH with a map of local rep factor alone. If the consistency level is DCQUORUMSYNC then it will return a DCQRH with a map of all the DC rep facor.

Overrides:
getWriteResponseHandler in class AbstractReplicationStrategy


Copyright © 2010 The Apache Software Foundation