Package net.spy.memcached
Class ArrayModNodeLocator
- java.lang.Object
-
- net.spy.memcached.ArrayModNodeLocator
-
- All Implemented Interfaces:
NodeLocator
public final class ArrayModNodeLocator extends java.lang.Object implements NodeLocator
NodeLocator implementation for dealing with simple array lookups using a modulus of the hash code and node list length.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classArrayModNodeLocator.NodeIterator
-
Field Summary
Fields Modifier and Type Field Description private HashAlgorithmhashAlgprivate MemcachedNode[]nodes
-
Constructor Summary
Constructors Modifier Constructor Description ArrayModNodeLocator(java.util.List<MemcachedNode> n, HashAlgorithm alg)Construct an ArraymodNodeLocator over the given array of nodes and using the given hash algorithm.privateArrayModNodeLocator(MemcachedNode[] n, HashAlgorithm alg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<MemcachedNode>getAll()Get all memcached nodes.MemcachedNodegetPrimary(java.lang.String k)Get the primary location for the given key.NodeLocatorgetReadonlyCopy()Create a read-only copy of this NodeLocator.java.util.Iterator<MemcachedNode>getSequence(java.lang.String k)Get an iterator over the sequence of nodes that make up the backup locations for a given key.private intgetServerForKey(java.lang.String key)voidupdateLocator(java.util.List<MemcachedNode> newNodes)Update locator status.
-
-
-
Field Detail
-
hashAlg
private final HashAlgorithm hashAlg
-
nodes
private MemcachedNode[] nodes
-
-
Constructor Detail
-
ArrayModNodeLocator
public ArrayModNodeLocator(java.util.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 nodesalg- the hash algorithm
-
ArrayModNodeLocator
private ArrayModNodeLocator(MemcachedNode[] n, HashAlgorithm alg)
-
-
Method Detail
-
getAll
public java.util.Collection<MemcachedNode> getAll()
Description copied from interface:NodeLocatorGet all memcached nodes. This is useful for broadcasting messages.- Specified by:
getAllin interfaceNodeLocator
-
getPrimary
public MemcachedNode getPrimary(java.lang.String k)
Description copied from interface:NodeLocatorGet the primary location for the given key.- Specified by:
getPrimaryin interfaceNodeLocator- Parameters:
k- the object key- Returns:
- the QueueAttachment containing the primary storage for a key
-
getSequence
public java.util.Iterator<MemcachedNode> getSequence(java.lang.String k)
Description copied from interface:NodeLocatorGet an iterator over the sequence of nodes that make up the backup locations for a given key.- Specified by:
getSequencein interfaceNodeLocator- Parameters:
k- the object key- Returns:
- the sequence of backup nodes.
-
getReadonlyCopy
public NodeLocator getReadonlyCopy()
Description copied from interface:NodeLocatorCreate a read-only copy of this NodeLocator.- Specified by:
getReadonlyCopyin interfaceNodeLocator
-
updateLocator
public void updateLocator(java.util.List<MemcachedNode> newNodes)
Description copied from interface:NodeLocatorUpdate locator status.- Specified by:
updateLocatorin interfaceNodeLocator- Parameters:
newNodes- New locator nodes.
-
getServerForKey
private int getServerForKey(java.lang.String key)
-
-