KetamaNodeLocator Class Reference

Inherits net::spy::SpyObject, and net::spy::memcached::NodeLocator.

Collaboration diagram for KetamaNodeLocator:

Collaboration graph
[legend]

List of all members.

Classes

class  KetamaIterator

Public Member Functions

Collection< MemcachedNodegetAll ()
MemcachedNode getPrimary (final String k)
Iterator< MemcachedNodegetSequence (String k)
 KetamaNodeLocator (List< MemcachedNode > nodes, HashAlgorithm alg)

Package Functions

long getMaxKey ()
MemcachedNode getNodeForKey (long hash)

Package Attributes

final Collection< MemcachedNodeallNodes
final HashAlgorithm hashAlg
final SortedMap< Long,
MemcachedNode
ketamaNodes

Static Package Attributes

static final int NUM_REPS = 160


Detailed Description

This is an implementation of the Ketama consistent hash strategy from last.fm. This implementation may not be compatible with libketama as hashing is considered separate from node location.

Note that this implementation does not currently supported weighted nodes.

See also:
http://www.last.fm/user/RJ/journal/2007/04/10/392555/

Constructor & Destructor Documentation

KetamaNodeLocator ( List< MemcachedNode nodes,
HashAlgorithm  alg 
)


Member Function Documentation

Collection<MemcachedNode> getAll (  ) 

Get all memcached nodes. This is useful for broadcasting messages.

Implements NodeLocator.

long getMaxKey (  )  [package]

MemcachedNode getNodeForKey ( long  hash  )  [package]

MemcachedNode getPrimary ( final String  k  ) 

Iterator<MemcachedNode> getSequence ( String  k  ) 

Get an iterator over the sequence of nodes that make up the backup locations for a given key.

Parameters:
k the object key
Returns:
the sequence of backup nodes.

Implements NodeLocator.


Member Data Documentation

final Collection<MemcachedNode> allNodes [package]

final HashAlgorithm hashAlg [package]

final SortedMap<Long, MemcachedNode> ketamaNodes [package]

Initial value:

                new TreeMap<Long, MemcachedNode>()

final int NUM_REPS = 160 [static, package]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:37 2012 for Project Wonder by  doxygen 1.5.8