Class ArrayModNodeLocator

  • All Implemented Interfaces:
    NodeLocator

    public final class ArrayModNodeLocator
    extends java.lang.Object
    implements NodeLocator
    NodeLocator implementation for dealing with simple array lookups using a modulus of the hash code and node list length.
    • Constructor Detail

      • ArrayModNodeLocator

        public ArrayModNodeLocator​(java.util.List<MemcachedNode> n,
                                   HashAlgorithm alg)
        Construct an ArraymodNodeLocator over the given array of nodes and using the given hash algorithm.
        Parameters:
        n - the array of nodes
        alg - the hash algorithm
    • Method Detail

      • getAll

        public java.util.Collection<MemcachedNode> getAll()
        Description copied from interface: NodeLocator
        Get all memcached nodes. This is useful for broadcasting messages.
        Specified by:
        getAll in interface NodeLocator
      • getPrimary

        public MemcachedNode getPrimary​(java.lang.String k)
        Description copied from interface: NodeLocator
        Get the primary location for the given key.
        Specified by:
        getPrimary in interface NodeLocator
        Parameters:
        k - the object key
        Returns:
        the QueueAttachment containing the primary storage for a key
      • getSequence

        public java.util.Iterator<MemcachedNode> getSequence​(java.lang.String k)
        Description copied from interface: NodeLocator
        Get an iterator over the sequence of nodes that make up the backup locations for a given key.
        Specified by:
        getSequence in interface NodeLocator
        Parameters:
        k - the object key
        Returns:
        the sequence of backup nodes.
      • updateLocator

        public void updateLocator​(java.util.List<MemcachedNode> newNodes)
        Description copied from interface: NodeLocator
        Update locator status.
        Specified by:
        updateLocator in interface NodeLocator
        Parameters:
        newNodes - New locator nodes.
      • getServerForKey

        private int getServerForKey​(java.lang.String key)