Package net.spy.memcached
Class KetamaIterator
- java.lang.Object
-
- net.spy.memcached.compat.SpyObject
-
- net.spy.memcached.KetamaIterator
-
- All Implemented Interfaces:
java.util.Iterator<MemcachedNode>
class KetamaIterator extends SpyObject implements java.util.Iterator<MemcachedNode>
Implements an Iterator which the KetamaNodeLoctaor may return to a client for iterating through alternate nodes for a given key.
-
-
Field Summary
Fields Modifier and Type Field Description private HashAlgorithmhashAlgprivate longhashValprivate java.util.TreeMap<java.lang.Long,MemcachedNode>ketamaNodesprivate java.lang.Stringkeyprivate intnumTriesprivate intremainingTries
-
Constructor Summary
Constructors Modifier Constructor Description protectedKetamaIterator(java.lang.String k, int t, java.util.TreeMap<java.lang.Long,MemcachedNode> ketamaNodes, HashAlgorithm hashAlg)Create a new KetamaIterator to be used by a client for an operation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private MemcachedNodegetNodeForKey(long hash)booleanhasNext()MemcachedNodenext()private voidnextHash()voidremove()
-
-
-
Field Detail
-
key
private final java.lang.String key
-
hashVal
private long hashVal
-
remainingTries
private int remainingTries
-
numTries
private int numTries
-
hashAlg
private final HashAlgorithm hashAlg
-
ketamaNodes
private final java.util.TreeMap<java.lang.Long,MemcachedNode> ketamaNodes
-
-
Constructor Detail
-
KetamaIterator
protected KetamaIterator(java.lang.String k, int t, java.util.TreeMap<java.lang.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 Detail
-
nextHash
private void nextHash()
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<MemcachedNode>
-
next
public MemcachedNode next()
- Specified by:
nextin interfacejava.util.Iterator<MemcachedNode>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<MemcachedNode>
-
getNodeForKey
private MemcachedNode getNodeForKey(long hash)
-
-