net.spy.memcached
Class KetamaNodeLocator
java.lang.Object
net.spy.SpyObject
net.spy.memcached.KetamaNodeLocator
- All Implemented Interfaces:
- NodeLocator
public final class KetamaNodeLocator
- extends net.spy.SpyObject
- implements NodeLocator
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.
- See Also:
http://www.last.fm/user/RJ/journal/2007/04/10/392555/
|
Method Summary |
java.util.Collection<MemcachedNode> |
getAll()
Get all memcached nodes. |
MemcachedNode |
getPrimary(java.lang.String k)
Get the primary location for the given key. |
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. |
| Methods inherited from class net.spy.SpyObject |
getLogger |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KetamaNodeLocator
public KetamaNodeLocator(java.util.List<MemcachedNode> nodes,
HashAlgorithm alg)
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.