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 HashAlgorithmprivate longprivate final TreeMap<Long, MemcachedNode> private final Stringprivate intprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedKetamaIterator(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 MemcachedNodegetNodeForKey(long hash) booleanhasNext()next()private voidnextHash()voidremove()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
hasNextin interfaceIterator<MemcachedNode>
-
next
- Specified by:
nextin interfaceIterator<MemcachedNode>
-
remove
public void remove()- Specified by:
removein interfaceIterator<MemcachedNode>
-
getNodeForKey
-