Package net.spy.memcached
Class KetamaIterator
java.lang.Object
net.spy.memcached.compat.SpyObject
net.spy.memcached.KetamaIterator
- All Implemented Interfaces:
Iterator<MemcachedNode>
Implements an Iterator which the KetamaNodeLoctaor may return to a client for
iterating through alternate nodes for a given key.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashAlgorithm
private long
private final TreeMap
<Long, MemcachedNode> private final String
private int
private int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
KetamaIterator
(String k, int t, TreeMap<Long, MemcachedNode> ketamaNodes, HashAlgorithm hashAlg) Create a new KetamaIterator to be used by a client for an operation. -
Method Summary
Modifier and TypeMethodDescriptionprivate MemcachedNode
getNodeForKey
(long hash) boolean
hasNext()
next()
private void
nextHash()
void
remove()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
key
-
hashVal
private long hashVal -
remainingTries
private int remainingTries -
numTries
private int numTries -
hashAlg
-
ketamaNodes
-
-
Constructor Details
-
KetamaIterator
protected KetamaIterator(String k, int t, TreeMap<Long, MemcachedNode> ketamaNodes, HashAlgorithm hashAlg) Create a new KetamaIterator to be used by a client for an operation.- Parameters:
k
- the key to iterate fort
- the number of tries until giving upketamaNodes
- the continuum in the form of a TreeMap to be used when selecting a nodehashAlg
- the hash algorithm to use when selecting within the continuumq
-
-
Method Details
-
nextHash
private void nextHash() -
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<MemcachedNode>
-
next
- Specified by:
next
in interfaceIterator<MemcachedNode>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<MemcachedNode>
-
getNodeForKey
-