org.apache.cassandra.locator
Class AbstractRackAwareSnitch

java.lang.Object
  extended by org.apache.cassandra.locator.AbstractEndpointSnitch
      extended by org.apache.cassandra.locator.AbstractRackAwareSnitch
All Implemented Interfaces:
IEndpointSnitch
Direct Known Subclasses:
PropertyFileSnitch, RackInferringSnitch

public abstract class AbstractRackAwareSnitch
extends AbstractEndpointSnitch

An endpoint snitch tells Cassandra information about network topology that it can use to route requests more efficiently.


Field Summary
 
Fields inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
subscribers
 
Constructor Summary
AbstractRackAwareSnitch()
           
 
Method Summary
 int compareEndpoints(java.net.InetAddress address, java.net.InetAddress a1, java.net.InetAddress a2)
          compares two endpoints in relation to the target endpoint, returning as Comparator.compare would
abstract  java.lang.String getDatacenter(java.net.InetAddress endpoint)
          Return the data center for which an endpoint resides in
abstract  java.lang.String getRack(java.net.InetAddress endpoint)
          Return the rack for which an endpoint resides in
 java.util.List<java.net.InetAddress> getSortedListByProximity(java.net.InetAddress address, java.util.Collection<java.net.InetAddress> addresses)
          Sorts the Collection of node addresses by proximity to the given address
 java.util.List<java.net.InetAddress> sortByProximity(java.net.InetAddress address, java.util.List<java.net.InetAddress> addresses)
          Sorts the List of node addresses by proximity to the given address
 
Methods inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
invalidateCachedSnitchValues, register
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRackAwareSnitch

public AbstractRackAwareSnitch()
Method Detail

getRack

public abstract java.lang.String getRack(java.net.InetAddress endpoint)
Return the rack for which an endpoint resides in

Parameters:
endpoint - a specified endpoint
Returns:
string of rack
Throws:
java.net.UnknownHostException

getDatacenter

public abstract java.lang.String getDatacenter(java.net.InetAddress endpoint)
Return the data center for which an endpoint resides in

Parameters:
endpoint - a specified endpoint
Returns:
string of data center
Throws:
java.net.UnknownHostException

getSortedListByProximity

public java.util.List<java.net.InetAddress> getSortedListByProximity(java.net.InetAddress address,
                                                                     java.util.Collection<java.net.InetAddress> addresses)
Sorts the Collection of node addresses by proximity to the given address

Specified by:
getSortedListByProximity in interface IEndpointSnitch
Specified by:
getSortedListByProximity in class AbstractEndpointSnitch
Parameters:
address - the address to sort by proximity to
addresses - the nodes to sort
Returns:
a new sorted List

sortByProximity

public java.util.List<java.net.InetAddress> sortByProximity(java.net.InetAddress address,
                                                            java.util.List<java.net.InetAddress> addresses)
Sorts the List of node addresses by proximity to the given address

Specified by:
sortByProximity in interface IEndpointSnitch
Specified by:
sortByProximity in class AbstractEndpointSnitch
Parameters:
address - the address to sort the proximity by
addresses - the nodes to sort
Returns:
the sorted List

compareEndpoints

public int compareEndpoints(java.net.InetAddress address,
                            java.net.InetAddress a1,
                            java.net.InetAddress a2)
Description copied from interface: IEndpointSnitch
compares two endpoints in relation to the target endpoint, returning as Comparator.compare would

Specified by:
compareEndpoints in interface IEndpointSnitch
Overrides:
compareEndpoints in class AbstractEndpointSnitch


Copyright © 2010 The Apache Software Foundation