net.spy.memcached
Class ArrayModNodeLocator

java.lang.Object
  extended by net.spy.memcached.ArrayModNodeLocator
All Implemented Interfaces:
NodeLocator

public final class ArrayModNodeLocator
extends Object
implements NodeLocator

NodeLocator implementation for dealing with simple array lookups using a modulus of the hash code and node list length.


Constructor Summary
ArrayModNodeLocator(List<MemcachedNode> n, HashAlgorithm alg)
          Construct an ArraymodNodeLocator over the given array of nodes and using the given hash algorithm.
 
Method Summary
 Collection<MemcachedNode> getAll()
          Get all memcached nodes.
 MemcachedNode getPrimary(String k)
          Get the primary location for the given key.
 NodeLocator getReadonlyCopy()
          Create a read-only copy of this NodeLocator.
 Iterator<MemcachedNode> getSequence(String k)
          Get an iterator over the sequence of nodes that make up the backup locations for a given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayModNodeLocator

public ArrayModNodeLocator(List<MemcachedNode> n,
                           HashAlgorithm alg)
Construct an ArraymodNodeLocator over the given array of nodes and using the given hash algorithm.

Parameters:
n - the array of nodes
alg - the hash algorithm
Method Detail

getAll

public Collection<MemcachedNode> getAll()
Description copied from interface: NodeLocator
Get all memcached nodes. This is useful for broadcasting messages.

Specified by:
getAll in interface NodeLocator

getPrimary

public MemcachedNode getPrimary(String k)
Description copied from interface: NodeLocator
Get the primary location for the given key.

Specified by:
getPrimary in interface NodeLocator
Parameters:
k - the object key
Returns:
the QueueAttachment containing the primary storage for a key

getSequence

public Iterator<MemcachedNode> getSequence(String k)
Description copied from interface: NodeLocator
Get an iterator over the sequence of nodes that make up the backup locations for a given key.

Specified by:
getSequence in interface NodeLocator
Parameters:
k - the object key
Returns:
the sequence of backup nodes.

getReadonlyCopy

public NodeLocator getReadonlyCopy()
Description copied from interface: NodeLocator
Create a read-only copy of this NodeLocator.

Specified by:
getReadonlyCopy in interface NodeLocator