Class 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 Detail

      • key

        private final java.lang.String key
      • hashVal

        private long hashVal
      • remainingTries

        private int remainingTries
      • numTries

        private int numTries
      • 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 for
        t - the number of tries until giving up
        ketamaNodes - the continuum in the form of a TreeMap to be used when selecting a node
        hashAlg - the hash algorithm to use when selecting within the continuumq
    • Method Detail

      • nextHash

        private void nextHash()
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<MemcachedNode>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<MemcachedNode>
      • getNodeForKey

        private MemcachedNode getNodeForKey​(long hash)