net.spy.memcached.vbucket
Class VBucketNodeLocator

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.vbucket.VBucketNodeLocator
All Implemented Interfaces:
NodeLocator

public class VBucketNodeLocator
extends SpyObject
implements NodeLocator

Implementation of the NodeLocator interface that contains vbucket hashing methods


Constructor Summary
VBucketNodeLocator(List<MemcachedNode> nodes, Config jsonConfig)
          Construct a VBucketNodeLocator over the given JSON configuration string.
 
Method Summary
 Collection<MemcachedNode> getAll()
          Get all memcached nodes.
 MemcachedNode getAlternative(String k, Collection<MemcachedNode> notMyVbucketNodes)
          Method returns the node that is not contained in the specified collection of the failed nodes
 MemcachedNode getPrimary(String k)
          Get the primary location for the given key.
 NodeLocator getReadonlyCopy()
          Create a read-only copy of this NodeLocator.
 Iterator<MemcachedNode> getSequence(String k)
          Get an iterator over the sequence of nodes that make up the backup locations for a given key.
 int getVBucketIndex(String key)
          Returns a vbucket index for the given key
 void updateLocator(List<MemcachedNode> nodes, Config config)
           
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VBucketNodeLocator

public VBucketNodeLocator(List<MemcachedNode> nodes,
                          Config jsonConfig)
Construct a VBucketNodeLocator over the given JSON configuration string.

Parameters:
nodes -
jsonConfig -
Method Detail

getPrimary

public MemcachedNode getPrimary(String k)
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)
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.

getAll

public Collection<MemcachedNode> getAll()
Get all memcached nodes. This is useful for broadcasting messages.

Specified by:
getAll in interface NodeLocator

getReadonlyCopy

public NodeLocator getReadonlyCopy()
Create a read-only copy of this NodeLocator.

Specified by:
getReadonlyCopy in interface NodeLocator

updateLocator

public void updateLocator(List<MemcachedNode> nodes,
                          Config config)

getVBucketIndex

public int getVBucketIndex(String key)
Returns a vbucket index for the given key

Parameters:
key - the key
Returns:
vbucket index

getAlternative

public MemcachedNode getAlternative(String k,
                                    Collection<MemcachedNode> notMyVbucketNodes)
Method returns the node that is not contained in the specified collection of the failed nodes

Parameters:
k - the key
notMyVbucketNodes - a collection of the nodes are excluded
Returns:
The first MemcachedNode which meets requirements