Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cassandra.locator
Class AbstractEndpointSnitch

    java.lang.Object
      org.apache.cassandra.locator.AbstractEndpointSnitch

All Implemented Interfaces:
  IEndPointSnitch

Direct Known Subclasses:
  DynamicEndpointSnitch, EndPointSnitch

    public abstract class AbstractEndpointSnitch

extends java.lang.Object
implements IEndPointSnitch

An endpoint snitch tells Cassandra information about network topology that it can use to route requests more efficiently (with "sortByProximity"). Of the abstract methods, isOnSameRack and isInSameDataCenter are always required; getLocation is only used by DatacenterShardStrategy.

Constructor Summary
`AbstractEndpointSnitch()`

Method Summary
`int` | `compareEndpoints(java.net.InetAddress target, 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` | `getLocation(java.net.InetAddress endpoint)` Determines the name of the datacenter this endpoint lives in.
`java.util.List<java.net.InetAddress>` | `getSortedListByProximity(java.net.InetAddress address, java.util.Collection<java.net.InetAddress> unsortedAddress)` returns a new List sorted by proximity to the given endpoint
`abstract boolean` | `isInSameDataCenter(java.net.InetAddress host, java.net.InetAddress host2)` Determines if 2 nodes are in the same data center.
`abstract boolean` | `isOnSameRack(java.net.InetAddress host, java.net.InetAddress host2)` Determines if 2 nodes are in the same rack in the data center.
`java.util.List<java.net.InetAddress>` | `sortByProximity(java.net.InetAddress address, java.util.List<java.net.InetAddress> addresses)` This method will sort the List according to the proximity of the given address.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractEndpointSnitch

    public AbstractEndpointSnitch()

Method Detail

### isOnSameRack

    public abstract boolean isOnSameRack(java.net.InetAddress host,
                                         java.net.InetAddress host2)
                                  throws java.net.UnknownHostException

  Determines if 2 nodes are in the same rack in the data center.

  Specified by:
    `isOnSameRack` in interface `IEndPointSnitch`
  Parameters:
    `host` - a specified endpoint
    `host2` - another specified endpoint
  Returns:
    true if on the same rack false otherwise
  Throws:
    `java.net.UnknownHostException`

### isInSameDataCenter

    public abstract boolean isInSameDataCenter(java.net.InetAddress host,
                                               java.net.InetAddress host2)
                                        throws java.net.UnknownHostException

  Determines if 2 nodes are in the same data center.

  Specified by:
    `isInSameDataCenter` in interface `IEndPointSnitch`
  Parameters:
    `host` - a specified endpoint
    `host2` - another specified endpoint
  Returns:
    true if in the same data center false otherwise
  Throws:
    `java.net.UnknownHostException`

### getLocation

    public abstract java.lang.String getLocation(java.net.InetAddress endpoint)
                                          throws java.net.UnknownHostException

  Determines the name of the datacenter this endpoint lives in.

  Specified by:
    `getLocation` in interface `IEndPointSnitch`
  Parameters:
    `endpoint` -
  Returns:
    the name of the datacenter the endpoint lives in
  Throws:
    `java.net.UnknownHostException`

### getSortedListByProximity

    public java.util.List<java.net.InetAddress> getSortedListByProximity(java.net.InetAddress address,
                                                                         java.util.Collection<java.net.InetAddress> unsortedAddress)

  Description copied from interface: `IEndPointSnitch`
  returns a new List sorted by proximity to the given endpoint

  Specified by:
    `getSortedListByProximity` in interface `IEndPointSnitch`

### sortByProximity

    public java.util.List<java.net.InetAddress> sortByProximity(java.net.InetAddress address,
                                                                java.util.List<java.net.InetAddress> addresses)

  Description copied from interface: `IEndPointSnitch`
  This method will sort the List according to the proximity of the given address.

  Specified by:
    `sortByProximity` in interface `IEndPointSnitch`

### compareEndpoints

    public int compareEndpoints(java.net.InetAddress target,
                                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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 The Apache Software Foundation