## org.apache.cassandra.locator
Class DatacenterShardStategy

    java.lang.Object
      org.apache.cassandra.locator.AbstractReplicationStrategy
          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_, snitch_`

Constructor Summary
`DatacenterShardStategy(TokenMetadata tokenMetadata, IEndPointSnitch snitch)`

Method Summary
`java.util.ArrayList<java.net.InetAddress>` `getNaturalEndpoints(Token token, TokenMetadata metadata, java.lang.String table)` get the endpoints that should store the given Token, for the given table.
`WriteResponseHandler` `getWriteResponseHandler(int blockFor, ConsistencyLevel consistency_level, java.lang.String table)` 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,
                                  IEndPointSnitch snitch)
                           throws java.net.UnknownHostException

Throws:
  `java.net.UnknownHostException`

Method Detail

### getNaturalEndpoints

    public java.util.ArrayList<java.net.InetAddress> getNaturalEndpoints(Token token,
                                                                         TokenMetadata metadata,
                                                                         java.lang.String table)

  Description copied from class: `AbstractReplicationStrategy`
  get the endpoints that should store the given Token, for the given table. 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.

  Specified by:
    `getNaturalEndpoints` in class `AbstractReplicationStrategy`

### getWriteResponseHandler

    public WriteResponseHandler getWriteResponseHandler(int blockFor,
                                                        ConsistencyLevel consistency_level,
                                                        java.lang.String table)

  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