Class ArrayModNodeLocator

java.lang.Object
net.spy.memcached.ArrayModNodeLocator
All Implemented Interfaces:
NodeLocator

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

  • Constructor Details

    • ArrayModNodeLocator

      public ArrayModNodeLocator(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
    • ArrayModNodeLocator

      private ArrayModNodeLocator(MemcachedNode[] n, HashAlgorithm alg)
  • Method Details

    • getAll

      public 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(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 Iterator<MemcachedNode> getSequence(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.
    • getReadonlyCopy

      public NodeLocator getReadonlyCopy()
      Description copied from interface: NodeLocator
      Create a read-only copy of this NodeLocator.
      Specified by:
      getReadonlyCopy in interface NodeLocator
    • updateLocator

      public void updateLocator(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(String key)