public final class KetamaNodeLocator extends SpyObject implements NodeLocator
Constructor and Description |
---|
KetamaNodeLocator(List<MemcachedNode> nodes,
HashAlgorithm alg)
Create a new KetamaNodeLocator using specified nodes and the specifed hash
algorithm.
|
KetamaNodeLocator(List<MemcachedNode> nodes,
HashAlgorithm alg,
KetamaNodeLocatorConfiguration conf)
Create a new KetamaNodeLocator using specified nodes and the specifed hash
algorithm and configuration.
|
Modifier and Type | Method and Description |
---|---|
Collection<MemcachedNode> |
getAll()
Get all memcached nodes.
|
protected TreeMap<Long,MemcachedNode> |
getKetamaNodes() |
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.
|
protected void |
setKetamaNodes(List<MemcachedNode> nodes)
Setup the KetamaNodeLocator with the list of nodes it should use.
|
void |
updateLocator(List<MemcachedNode> nodes)
Update locator status.
|
public KetamaNodeLocator(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(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
- public Collection<MemcachedNode> getAll()
NodeLocator
getAll
in interface NodeLocator
public MemcachedNode getPrimary(String k)
NodeLocator
getPrimary
in interface NodeLocator
k
- the object keypublic Iterator<MemcachedNode> getSequence(String k)
NodeLocator
getSequence
in interface NodeLocator
k
- the object keypublic NodeLocator getReadonlyCopy()
NodeLocator
getReadonlyCopy
in interface NodeLocator
public void updateLocator(List<MemcachedNode> nodes)
NodeLocator
updateLocator
in interface NodeLocator
nodes
- New locator nodes.protected TreeMap<Long,MemcachedNode> getKetamaNodes()
protected void setKetamaNodes(List<MemcachedNode> nodes)
nodes
- a List of MemcachedNodes for this KetamaNodeLocator to use in
its continuumCopyright © 2016. All rights reserved.