Package net.spy.memcached.util
Class DefaultKetamaNodeLocatorConfiguration
- java.lang.Object
-
- net.spy.memcached.util.DefaultKetamaNodeLocatorConfiguration
-
- All Implemented Interfaces:
KetamaNodeLocatorConfiguration
public class DefaultKetamaNodeLocatorConfiguration extends java.lang.Object implements KetamaNodeLocatorConfiguration
A Default implementation of the configuration required for the KetamaNodeLocator algorithm to run.
-
-
Field Summary
Fields Modifier and Type Field Description private KetamaNodeKeyFormatter
ketamaNodeKeyFormatter
private int
numReps
-
Constructor Summary
Constructors Constructor Description DefaultKetamaNodeLocatorConfiguration()
Create a KetamaNodeLocatorConfiguraiton with the default SPYMEMCACHED node key formatDefaultKetamaNodeLocatorConfiguration(KetamaNodeKeyFormatter nodeKeyFormatter)
Create a KetamaNodeLocatorConfiguraiton
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getKeyForNode(MemcachedNode node, int repetition)
Delegates to the KetamaNodeKeyFormatterint
getNodeRepetitions()
Returns the number of discrete hashes that should be defined for each node in the continuum.
-
-
-
Field Detail
-
numReps
private final int numReps
- See Also:
- Constant Field Values
-
ketamaNodeKeyFormatter
private final KetamaNodeKeyFormatter ketamaNodeKeyFormatter
-
-
Constructor Detail
-
DefaultKetamaNodeLocatorConfiguration
public DefaultKetamaNodeLocatorConfiguration()
Create a KetamaNodeLocatorConfiguraiton with the default SPYMEMCACHED node key format
-
DefaultKetamaNodeLocatorConfiguration
public DefaultKetamaNodeLocatorConfiguration(KetamaNodeKeyFormatter nodeKeyFormatter)
Create a KetamaNodeLocatorConfiguraiton- Parameters:
nodeKeyFormatter
- Ketama node key format, either SPYMEMCACHED or LIBMEMCACHED
-
-
Method Detail
-
getNodeRepetitions
public int getNodeRepetitions()
Returns the number of discrete hashes that should be defined for each node in the continuum.- Specified by:
getNodeRepetitions
in interfaceKetamaNodeLocatorConfiguration
- Returns:
- NUM_REPS repetitions.
-
getKeyForNode
public java.lang.String getKeyForNode(MemcachedNode node, int repetition)
Delegates to the KetamaNodeKeyFormatter- Specified by:
getKeyForNode
in interfaceKetamaNodeLocatorConfiguration
- Parameters:
node
- The MemcachedNode to use to form the unique identifierrepetition
- The repetition number for the particular node in question (0 is the first repetition)- Returns:
- The key that represents the specific repetition of the node
-
-