public class VBucketNodeLocator extends SpyObject implements NodeLocator
NodeLocator
interface that contains vbucket
hashing methods.Constructor and Description |
---|
VBucketNodeLocator(java.util.List<MemcachedNode> nodes,
Config jsonConfig)
Construct a VBucketNodeLocator over the given JSON configuration string.
|
Modifier and Type | Method and Description |
---|---|
java.util.Collection<MemcachedNode> |
getAll()
Get all memcached nodes.
|
MemcachedNode |
getAlternative(java.lang.String k,
java.util.Collection<MemcachedNode> notMyVbucketNodes)
Method returns the node that is not contained in the specified collection
of the failed nodes.
|
MemcachedNode |
getPrimary(java.lang.String k)
Get the primary location for the given key.
|
NodeLocator |
getReadonlyCopy()
Create a read-only copy of this NodeLocator.
|
MemcachedNode |
getReplica(java.lang.String key,
int index)
Return a replica node for the given key and replica index.
|
java.util.List<java.lang.Integer> |
getReplicaIndexes(java.lang.String key)
Gets a list of vBucket indexes for the current replicas defined.
|
java.util.Iterator<MemcachedNode> |
getSequence(java.lang.String k)
Get an iterator over the sequence of nodes that make up the backup
locations for a given key.
|
MemcachedNode |
getServerByIndex(int k) |
int |
getVBucketIndex(java.lang.String key)
Returns a vbucket index for the given key.
|
boolean |
hasActiveMaster(java.lang.String key)
Checks if in the current vbucket the master is not "-1".
|
void |
updateLocator(java.util.Collection<MemcachedNode> nodes,
Config newconf) |
void |
updateLocator(java.util.List<MemcachedNode> nodes)
Update locator status.
|
public VBucketNodeLocator(java.util.List<MemcachedNode> nodes, Config jsonConfig)
nodes
- jsonConfig
- public MemcachedNode getPrimary(java.lang.String k)
getPrimary
in interface NodeLocator
k
- the object keypublic MemcachedNode getReplica(java.lang.String key, int index)
key
- the key to find the node for.index
- the Nth replica numberjava.lang.RuntimeException
- when no replica is defined for the given keypublic MemcachedNode getServerByIndex(int k)
public java.util.Iterator<MemcachedNode> getSequence(java.lang.String k)
getSequence
in interface NodeLocator
k
- the object keypublic java.util.Collection<MemcachedNode> getAll()
getAll
in interface NodeLocator
public NodeLocator getReadonlyCopy()
getReadonlyCopy
in interface NodeLocator
public void updateLocator(java.util.List<MemcachedNode> nodes)
NodeLocator
updateLocator
in interface NodeLocator
nodes
- New locator nodes.public void updateLocator(java.util.Collection<MemcachedNode> nodes, Config newconf)
public int getVBucketIndex(java.lang.String key)
key
- the keypublic MemcachedNode getAlternative(java.lang.String k, java.util.Collection<MemcachedNode> notMyVbucketNodes)
k
- the keynotMyVbucketNodes
- a collection of the nodes are excludedpublic java.util.List<java.lang.Integer> getReplicaIndexes(java.lang.String key)
key
- the key to check for.public boolean hasActiveMaster(java.lang.String key)
key
- the key to check for.Copyright © 2006-2009 Dustin Sallings, 2009-2014 Couchbase, Inc.