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) class
ArrayModNodeLocator.NodeIterator
-
Field Summary
Fields Modifier and Type Field Description private HashAlgorithm
hashAlg
private 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.private
ArrayModNodeLocator(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.MemcachedNode
getPrimary(java.lang.String k)
Get the primary location for the given key.NodeLocator
getReadonlyCopy()
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 int
getServerForKey(java.lang.String key)
void
updateLocator(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:NodeLocator
Get all memcached nodes. This is useful for broadcasting messages.- Specified by:
getAll
in interfaceNodeLocator
-
getPrimary
public MemcachedNode getPrimary(java.lang.String k)
Description copied from interface:NodeLocator
Get the primary location for the given key.- Specified by:
getPrimary
in 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:NodeLocator
Get an iterator over the sequence of nodes that make up the backup locations for a given key.- Specified by:
getSequence
in interfaceNodeLocator
- 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 interfaceNodeLocator
-
updateLocator
public void updateLocator(java.util.List<MemcachedNode> newNodes)
Description copied from interface:NodeLocator
Update locator status.- Specified by:
updateLocator
in interfaceNodeLocator
- Parameters:
newNodes
- New locator nodes.
-
getServerForKey
private int getServerForKey(java.lang.String key)
-
-