|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.spy.memcached.compat.SpyObject
net.spy.memcached.KetamaNodeLocator
public final class KetamaNodeLocator
This is an implementation of the Ketama consistent hash strategy from last.fm. This implementation may not be compatible with libketama as hashing is considered separate from node location. Note that this implementation does not currently supported weighted nodes.
Constructor Summary | |
---|---|
KetamaNodeLocator(java.util.List<MemcachedNode> nodes,
HashAlgorithm alg)
Create a new KetamaNodeLocator using specified nodes and the specifed hash algorithm. |
|
KetamaNodeLocator(java.util.List<MemcachedNode> nodes,
HashAlgorithm alg,
KetamaNodeLocatorConfiguration conf)
Create a new KetamaNodeLocator using specified nodes and the specifed hash algorithm and configuration. |
Method Summary | |
---|---|
java.util.Collection<MemcachedNode> |
getAll()
Get all memcached nodes. |
protected java.util.TreeMap<java.lang.Long,MemcachedNode> |
getKetamaNodes()
|
MemcachedNode |
getPrimary(java.lang.String k)
Get the primary location for the given key. |
NodeLocator |
getReadonlyCopy()
Create a read-only copy of this NodeLocator. |
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. |
protected void |
setKetamaNodes(java.util.List<MemcachedNode> nodes)
Setup the KetamaNodeLocator with the list of nodes it should use. |
void |
updateLocator(java.util.List<MemcachedNode> nodes)
Update locator status. |
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 |
---|
public KetamaNodeLocator(java.util.List<MemcachedNode> nodes, HashAlgorithm alg)
nodes
- The List of nodes to use in the Ketama consistent hash
continuumalg
- The hash algorithm to use when choosing a node in the Ketama
consistent hash continuumpublic KetamaNodeLocator(java.util.List<MemcachedNode> nodes, HashAlgorithm alg, KetamaNodeLocatorConfiguration conf)
nodes
- The List of nodes to use in the Ketama consistent hash
continuumalg
- The hash algorithm to use when choosing a node in the Ketama
consistent hash continuumconf
- Method Detail |
---|
public java.util.Collection<MemcachedNode> getAll()
NodeLocator
getAll
in interface NodeLocator
public MemcachedNode getPrimary(java.lang.String k)
NodeLocator
getPrimary
in interface NodeLocator
k
- the object key
public java.util.Iterator<MemcachedNode> getSequence(java.lang.String k)
NodeLocator
getSequence
in interface NodeLocator
k
- the object key
public NodeLocator getReadonlyCopy()
NodeLocator
getReadonlyCopy
in interface NodeLocator
public void updateLocator(java.util.List<MemcachedNode> nodes)
NodeLocator
updateLocator
in interface NodeLocator
nodes
- New locator nodes.protected java.util.TreeMap<java.lang.Long,MemcachedNode> getKetamaNodes()
protected void setKetamaNodes(java.util.List<MemcachedNode> nodes)
nodes
- a List of MemcachedNodes for this KetamaNodeLocator to use in
its continuum
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |