public class DefaultKetamaNodeLocatorConfiguration extends Object implements KetamaNodeLocatorConfiguration
Modifier and Type | Field and Description |
---|---|
protected Map<MemcachedNode,String> |
socketAddresses |
Constructor and Description |
---|
DefaultKetamaNodeLocatorConfiguration() |
Modifier and Type | Method and Description |
---|---|
String |
getKeyForNode(MemcachedNode node,
int repetition)
Returns a uniquely identifying key, suitable for hashing by the
KetamaNodeLocator algorithm.
|
int |
getNodeRepetitions()
Returns the number of discrete hashes that should be defined for each node
in the continuum.
|
protected String |
getSocketAddressForNode(MemcachedNode node)
Returns the socket address of a given MemcachedNode.
|
protected Map<MemcachedNode,String> socketAddresses
public DefaultKetamaNodeLocatorConfiguration()
protected String getSocketAddressForNode(MemcachedNode node)
node
- The node which we're interested inpublic int getNodeRepetitions()
getNodeRepetitions
in interface KetamaNodeLocatorConfiguration
public String getKeyForNode(MemcachedNode node, int repetition)
This default implementation uses the socket-address of the MemcachedNode and concatenates it with a hyphen directly against the repetition number for example a key for a particular server's first repetition may look like:
myhost/10.0.2.1-0
for the second repetition
myhost/10.0.2.1-1
for a server where reverse lookups are failing the returned keys may look like
/10.0.2.1-0
and /10.0.2.1-1
getKeyForNode
in interface KetamaNodeLocatorConfiguration
node
- The MemcachedNode to use to form the unique identifierrepetition
- The repetition number for the particular node in question
(0 is the first repetition)Copyright © 2021. All rights reserved.