Package net.rubyeye.xmemcached.impl
Class KetamaMemcachedSessionLocator
java.lang.Object
net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator
- All Implemented Interfaces:
MemcachedSessionLocator
Consistent Hash Algorithm implementation,based on TreeMap.tailMap(hash) method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
(package private) static final int
compatible with nginx-upstream-consistent,patched by wolfg1969private final boolean
private final HashAlgorithm
private int
(package private) static final int
Fields inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
failureMode
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a KetamaMemcachedSessionLocator with default config.KetamaMemcachedSessionLocator
(boolean cwNginxUpstreamConsistent) Create a KetamaMemcachedSessionLocatorKetamaMemcachedSessionLocator
(List<Session> list, HashAlgorithm alg) Create a KetamaMemcachedSessionLocator with a special hash algorithm.KetamaMemcachedSessionLocator
(HashAlgorithm alg, boolean cwNginxUpstreamConsistent) KetamaMemcachedSessionLocator
(HashAlgorithm alg, boolean cwNginxUpstreamConsistent, boolean gwhalinMemcachedJavaClientCompatibiltyConsistent) -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
buildMap
(Collection<Session> list, HashAlgorithm alg) final Session
getSessionByHash
(long hash) final Session
getSessionByKey
(String key) Returns a session by special key.getSessionList
(TreeMap<Long, List<Session>> sessionMap, long k) private String
getSockStr
(Session session) final long
final void
updateSessions
(Collection<Session> list) Update sessions when session was added or removed.Methods inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
setFailureMode
-
Field Details
-
NUM_REPS
static final int NUM_REPS- See Also:
-
ketamaSessions
-
hashAlg
-
maxTries
private int maxTries -
DEFAULT_PORT
static final int DEFAULT_PORTcompatible with nginx-upstream-consistent,patched by wolfg1969- See Also:
-
cwNginxUpstreamConsistent
private final boolean cwNginxUpstreamConsistent -
gwhalinMemcachedJavaClientCompatibiltyConsistent
private final boolean gwhalinMemcachedJavaClientCompatibiltyConsistent
-
-
Constructor Details
-
KetamaMemcachedSessionLocator
public KetamaMemcachedSessionLocator()Create a KetamaMemcachedSessionLocator with default config. -
KetamaMemcachedSessionLocator
public KetamaMemcachedSessionLocator(boolean cwNginxUpstreamConsistent) Create a KetamaMemcachedSessionLocator- Parameters:
cwNginxUpstreamConsistent
- true if compatible with nginx up stream memcached consistent algorithm.
-
KetamaMemcachedSessionLocator
Create a KetamaMemcachedSessionLocator with a special hash algorithm.- Parameters:
alg
-
-
KetamaMemcachedSessionLocator
-
KetamaMemcachedSessionLocator
public KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent, boolean gwhalinMemcachedJavaClientCompatibiltyConsistent) -
KetamaMemcachedSessionLocator
-
-
Method Details
-
buildMap
-
getSockStr
-
getSessionList
-
getSessionByKey
Description copied from interface:MemcachedSessionLocator
Returns a session by special key.- Parameters:
key
-- Returns:
-
getSessionByHash
-
nextHash
-
updateSessions
Description copied from interface:MemcachedSessionLocator
Update sessions when session was added or removed.- Parameters:
list
- The newer sessions
-