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 HashAlgorithm
hashAlg
private long
hashVal
private java.util.TreeMap<java.lang.Long,MemcachedNode>
ketamaNodes
private java.lang.String
key
private int
numTries
private int
remainingTries
-
Constructor Summary
Constructors Modifier Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private MemcachedNode
getNodeForKey(long hash)
boolean
hasNext()
MemcachedNode
next()
private void
nextHash()
void
remove()
-
-
-
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:
hasNext
in interfacejava.util.Iterator<MemcachedNode>
-
next
public MemcachedNode next()
- Specified by:
next
in interfacejava.util.Iterator<MemcachedNode>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<MemcachedNode>
-
getNodeForKey
private MemcachedNode getNodeForKey(long hash)
-
-