org.apache.cassandra.locator
Class DynamicEndpointSnitch

java.lang.Object
  extended by org.apache.cassandra.locator.AbstractEndpointSnitch
      extended by org.apache.cassandra.locator.DynamicEndpointSnitch
All Implemented Interfaces:
DynamicEndpointSnitchMBean, IEndpointSnitch, ILatencySubscriber

public class DynamicEndpointSnitch
extends AbstractEndpointSnitch
implements ILatencySubscriber, DynamicEndpointSnitchMBean

A dynamic snitch that sorts endpoints by latency with an adapted phi failure detector


Field Summary
 IEndpointSnitch subsnitch
           
 
Fields inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
subscribers
 
Constructor Summary
DynamicEndpointSnitch(IEndpointSnitch snitch)
           
 
Method Summary
 void cacheEndpoint(Token t, java.util.ArrayList<java.net.InetAddress> addr)
          puts an address in the cache for a given token.
 void clearEndpointCache()
          clears all cache values.
 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
 java.util.ArrayList<java.net.InetAddress> getCachedEndpoints(Token t)
          returns a list of cached endpoints for a given token.
 java.lang.String getDatacenter(java.net.InetAddress endpoint)
          returns a String representing the datacenter this endpoint belongs to
 java.lang.String getRack(java.net.InetAddress endpoint)
          returns a String repesenting the rack this endpoint belongs to
 java.util.Map<java.net.InetAddress,java.lang.Double> getScores()
           
 java.util.List<java.net.InetAddress> getSortedListByProximity(java.net.InetAddress address, java.util.Collection<java.net.InetAddress> addresses)
          returns a new List sorted by proximity to the given endpoint
 void receiveTiming(java.net.InetAddress host, java.lang.Double latency)
           
 java.util.List<java.net.InetAddress> sortByProximity(java.net.InetAddress address, java.util.List<java.net.InetAddress> addresses)
          This method will sort the List by proximity to the given address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subsnitch

public IEndpointSnitch subsnitch
Constructor Detail

DynamicEndpointSnitch

public DynamicEndpointSnitch(IEndpointSnitch snitch)
Method Detail

getCachedEndpoints

public java.util.ArrayList<java.net.InetAddress> getCachedEndpoints(Token t)
Description copied from interface: IEndpointSnitch
returns a list of cached endpoints for a given token.

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

cacheEndpoint

public void cacheEndpoint(Token t,
                          java.util.ArrayList<java.net.InetAddress> addr)
Description copied from interface: IEndpointSnitch
puts an address in the cache for a given token.

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

clearEndpointCache

public void clearEndpointCache()
Description copied from interface: IEndpointSnitch
clears all cache values.

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

getRack

public java.lang.String getRack(java.net.InetAddress endpoint)
Description copied from interface: IEndpointSnitch
returns a String repesenting the rack this endpoint belongs to

Specified by:
getRack in interface IEndpointSnitch

getDatacenter

public java.lang.String getDatacenter(java.net.InetAddress endpoint)
Description copied from interface: IEndpointSnitch
returns a String representing the datacenter this endpoint belongs to

Specified by:
getDatacenter in interface IEndpointSnitch

getSortedListByProximity

public java.util.List<java.net.InetAddress> getSortedListByProximity(java.net.InetAddress address,
                                                                     java.util.Collection<java.net.InetAddress> addresses)
Description copied from interface: IEndpointSnitch
returns a new List sorted by proximity to the given endpoint

Specified by:
getSortedListByProximity in interface IEndpointSnitch
Specified by:
getSortedListByProximity in class AbstractEndpointSnitch

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 by proximity to the given address.

Specified by:
sortByProximity in interface IEndpointSnitch
Specified by:
sortByProximity in class AbstractEndpointSnitch

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
Overrides:
compareEndpoints in class AbstractEndpointSnitch

receiveTiming

public void receiveTiming(java.net.InetAddress host,
                          java.lang.Double latency)
Specified by:
receiveTiming in interface ILatencySubscriber

getScores

public java.util.Map<java.net.InetAddress,java.lang.Double> getScores()
Specified by:
getScores in interface DynamicEndpointSnitchMBean


Copyright © 2010 The Apache Software Foundation