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 intDEFAULT_NUM_REPSprivate HashAlgorithmhashAlgorithmprivate java.util.TreeMap<java.lang.Long,java.util.List<Session>>ketamaSessionsprivate intmaxTriesprivate intnumRepsprivate java.util.Randomrandom-
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 voidbuildMap(java.util.Collection<Session> list, HashAlgorithm alg)SessiongetSessionByHash(long hash)SessiongetSessionByKey(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)longnextHash(long hashVal, java.lang.String key, int tries)voidupdateSessions(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:MemcachedSessionLocatorReturns 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:MemcachedSessionLocatorUpdate sessions when session was added or removed.- Parameters:
list- The newer sessions
-
-