Package net.rubyeye.xmemcached.impl
Class LibmemcachedMemcachedSessionLocator
- java.lang.Object
-
- net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
-
- net.rubyeye.xmemcached.impl.LibmemcachedMemcachedSessionLocator
-
- All Implemented Interfaces:
MemcachedSessionLocator
public class LibmemcachedMemcachedSessionLocator extends AbstractMemcachedSessionLocator
Consistent Hash Algorithm implementation is compatible with libmemcached method.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
DEFAULT_NUM_REPS
private HashAlgorithm
hashAlgorithm
private java.util.TreeMap<java.lang.Long,java.util.List<Session>>
ketamaSessions
private int
maxTries
private int
numReps
private java.util.Random
random
-
Fields inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
failureMode
-
-
Constructor Summary
Constructors Constructor Description LibmemcachedMemcachedSessionLocator()
LibmemcachedMemcachedSessionLocator(int numReps, HashAlgorithm hashAlgorithm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buildMap(java.util.Collection<Session> list, HashAlgorithm alg)
Session
getSessionByHash(long hash)
Session
getSessionByKey(java.lang.String key)
Returns a session by special key.private java.util.List<Session>
getSessionList(java.util.TreeMap<java.lang.Long,java.util.List<Session>> sessionMap, long k)
long
nextHash(long hashVal, java.lang.String key, int tries)
void
updateSessions(java.util.Collection<Session> list)
Update sessions when session was added or removed.-
Methods inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
setFailureMode
-
-
-
-
Field Detail
-
DEFAULT_NUM_REPS
static final int DEFAULT_NUM_REPS
- See Also:
- Constant Field Values
-
ketamaSessions
private transient volatile java.util.TreeMap<java.lang.Long,java.util.List<Session>> ketamaSessions
-
maxTries
private int maxTries
-
numReps
private int numReps
-
random
private final java.util.Random random
-
hashAlgorithm
private HashAlgorithm hashAlgorithm
-
-
Constructor Detail
-
LibmemcachedMemcachedSessionLocator
public LibmemcachedMemcachedSessionLocator()
-
LibmemcachedMemcachedSessionLocator
public LibmemcachedMemcachedSessionLocator(int numReps, HashAlgorithm hashAlgorithm)
-
-
Method Detail
-
buildMap
private final void buildMap(java.util.Collection<Session> list, HashAlgorithm alg)
-
getSessionList
private java.util.List<Session> getSessionList(java.util.TreeMap<java.lang.Long,java.util.List<Session>> sessionMap, long k)
-
getSessionByKey
public final Session getSessionByKey(java.lang.String key)
Description copied from interface:MemcachedSessionLocator
Returns a session by special key.- Returns:
-
getSessionByHash
public final Session getSessionByHash(long hash)
-
nextHash
public final long nextHash(long hashVal, java.lang.String key, int tries)
-
updateSessions
public final void updateSessions(java.util.Collection<Session> list)
Description copied from interface:MemcachedSessionLocator
Update sessions when session was added or removed.- Parameters:
list
- The newer sessions
-
-