public final class KetamaNodeLocator extends SpyObject implements NodeLocator
Constructor and Description |
---|
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,
KetamaNodeKeyFormatter.Format nodeKeyFormat,
java.util.Map<java.net.InetSocketAddress,java.lang.Integer> weights)
Create a new KetamaNodeLocator with specific nodes, hash, node key format,
and weight
|
KetamaNodeLocator(java.util.List<MemcachedNode> nodes,
HashAlgorithm alg,
KetamaNodeLocatorConfiguration conf)
Create a new KetamaNodeLocator using specified nodes and the specifed hash
algorithm and configuration.
|
KetamaNodeLocator(java.util.List<MemcachedNode> nodes,
HashAlgorithm alg,
java.util.Map<java.net.InetSocketAddress,java.lang.Integer> nodeWeights,
KetamaNodeLocatorConfiguration configuration)
Create a new KetamaNodeLocator with specific nodes, hash, node key format,
and weight
|
Modifier and Type | Method and Description |
---|---|
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.
|
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, KetamaNodeKeyFormatter.Format nodeKeyFormat, java.util.Map<java.net.InetSocketAddress,java.lang.Integer> weights)
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 continuumnodeKeyFormat
- the format used to name the nodes in Ketama, either
SPYMEMCACHED or LIBMEMCACHEDweights
- node weights for ketama, a map from InetSocketAddress to
weight as Integerpublic 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
- public KetamaNodeLocator(java.util.List<MemcachedNode> nodes, HashAlgorithm alg, java.util.Map<java.net.InetSocketAddress,java.lang.Integer> nodeWeights, KetamaNodeLocatorConfiguration configuration)
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 continuumweights
- node weights for ketama, a map from InetSocketAddress to
weight as Integerconfiguration
- node locator configurationpublic 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 keypublic java.util.Iterator<MemcachedNode> getSequence(java.lang.String k)
NodeLocator
getSequence
in interface NodeLocator
k
- the object keypublic 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 continuumCopyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.