Package org.apache.cassandra.locator
Class SimpleSnitch
- java.lang.Object
-
- org.apache.cassandra.locator.AbstractEndpointSnitch
-
- org.apache.cassandra.locator.SimpleSnitch
-
- All Implemented Interfaces:
IEndpointSnitch
public class SimpleSnitch extends AbstractEndpointSnitch
A simple endpoint snitch implementation that treats Strategy order as proximity, allowing non-read-repaired reads to prefer a single endpoint, which improves cache locality.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDATA_CENTER_NAMEstatic java.lang.StringRACK_NAME
-
Constructor Summary
Constructors Constructor Description SimpleSnitch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareEndpoints(InetAddressAndPort target, Replica r1, Replica r2)compares two endpoints in relation to the target endpoint, returning as Comparator.compare wouldjava.lang.StringgetDatacenter(InetAddressAndPort endpoint)returns a String representing the datacenter the given endpoint belongs tojava.lang.StringgetRack(InetAddressAndPort endpoint)returns a String representing the rack the given endpoint belongs to<C extends ReplicaCollection<? extends C>>
CsortedByProximity(InetAddressAndPort address, C unsortedAddress)Sorts the Collection of node addresses by proximity to the given address-
Methods inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
gossiperStarting, isWorthMergingForRangeQuery
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.locator.IEndpointSnitch
getDatacenter, getDatacenter, getLocalDatacenter, getLocalRack, validate
-
-
-
-
Field Detail
-
DATA_CENTER_NAME
public static final java.lang.String DATA_CENTER_NAME
- See Also:
- Constant Field Values
-
RACK_NAME
public static final java.lang.String RACK_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRack
public java.lang.String getRack(InetAddressAndPort endpoint)
Description copied from interface:IEndpointSnitchreturns a String representing the rack the given endpoint belongs to
-
getDatacenter
public java.lang.String getDatacenter(InetAddressAndPort endpoint)
Description copied from interface:IEndpointSnitchreturns a String representing the datacenter the given endpoint belongs to
-
sortedByProximity
public <C extends ReplicaCollection<? extends C>> C sortedByProximity(InetAddressAndPort address, C unsortedAddress)
Description copied from class:AbstractEndpointSnitchSorts the Collection of node addresses by proximity to the given address- Specified by:
sortedByProximityin interfaceIEndpointSnitch- Overrides:
sortedByProximityin classAbstractEndpointSnitch- Parameters:
address- the address to sort by proximity tounsortedAddress- the nodes to sort- Returns:
- a new sorted List
-
compareEndpoints
public int compareEndpoints(InetAddressAndPort target, Replica r1, Replica r2)
Description copied from interface:IEndpointSnitchcompares two endpoints in relation to the target endpoint, returning as Comparator.compare would- Specified by:
compareEndpointsin interfaceIEndpointSnitch- Specified by:
compareEndpointsin classAbstractEndpointSnitch
-
-