Package net.spy.memcached
Class KetamaConnectionFactory
- java.lang.Object
-
- net.spy.memcached.compat.SpyObject
-
- net.spy.memcached.DefaultConnectionFactory
-
- net.spy.memcached.KetamaConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
public class KetamaConnectionFactory extends DefaultConnectionFactory
ConnectionFactory instance that sets up a ketama compatible connection.This implementation piggy-backs on the functionality of the
DefaultConnectionFactory
in terms of connections and queue handling. Where it differs is that it uses both theKetamaNodeLocator
and theHashAlgorithm.KETAMA_HASH
to provide consistent node hashing.- See Also:
- RJ's blog post
-
-
Field Summary
Fields Modifier and Type Field Description private KetamaNodeKeyFormatter.Format
ketamaNodeKeyFormat
private java.util.Map<java.net.InetSocketAddress,java.lang.Integer>
weights
-
Fields inherited from class net.spy.memcached.DefaultConnectionFactory
DEFAULT_AUTH_WAIT_TIME, DEFAULT_FAILURE_MODE, DEFAULT_HASH, DEFAULT_MAX_RECONNECT_DELAY, DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD, DEFAULT_METRIC_TYPE, DEFAULT_OP_QUEUE_LEN, DEFAULT_OP_QUEUE_MAX_BLOCK_TIME, DEFAULT_OPERATION_TIMEOUT, DEFAULT_READ_BUFFER_SIZE, opQueueLen
-
-
Constructor Summary
Constructors Constructor Description KetamaConnectionFactory()
Create a KetamaConnectionFactory with the default parameters.KetamaConnectionFactory(int qLen, int bufSize, long opQueueMaxBlockTime)
Create a KetamaConnectionFactory with the given maximum operation queue length, and the given read buffer size.KetamaConnectionFactory(int qLen, int bufSize, long opQueueMaxBlockTime, HashAlgorithm hash, KetamaNodeKeyFormatter.Format nodeKeyFormat, java.util.Map<java.net.InetSocketAddress,java.lang.Integer> weights)
Create a KetamaConnectionFactory with the maximum operation queue length, the given read buffer size, the maximum time to block waiting operations, a specific hash algorithm, a set ring key format, and a given set of weights.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeLocator
createLocator(java.util.List<MemcachedNode> nodes)
Create a NodeLocator instance for the given list of nodes.KetamaNodeKeyFormatter.Format
getKetamaNodeKeyFormat()
java.util.Map<java.net.InetSocketAddress,java.lang.Integer>
getWeights()
-
Methods inherited from class net.spy.memcached.DefaultConnectionFactory
createConnection, createMemcachedNode, createOperationQueue, createReadOperationQueue, createWriteOperationQueue, enableMetrics, getAuthDescriptor, getAuthWaitTime, getDefaultTranscoder, getFailureMode, getHashAlg, getInitialObservers, getListenerExecutorService, getMaxReconnectDelay, getMetricCollector, getName, getOperationFactory, getOperationTimeout, getOpQueueLen, getOpQueueMaxBlockTime, getReadBufSize, getTimeoutExceptionThreshold, isDaemon, isDefaultExecutorService, shouldOptimize, toString, useNagleAlgorithm
-
-
-
-
Field Detail
-
ketamaNodeKeyFormat
private final KetamaNodeKeyFormatter.Format ketamaNodeKeyFormat
-
weights
private java.util.Map<java.net.InetSocketAddress,java.lang.Integer> weights
-
-
Constructor Detail
-
KetamaConnectionFactory
public KetamaConnectionFactory(int qLen, int bufSize, long opQueueMaxBlockTime)
Create a KetamaConnectionFactory with the given maximum operation queue length, and the given read buffer size.- Parameters:
opQueueMaxBlockTime
- the maximum time to block waiting for op queue operations to complete, in milliseconds
-
KetamaConnectionFactory
public KetamaConnectionFactory(int qLen, int bufSize, long opQueueMaxBlockTime, HashAlgorithm hash, KetamaNodeKeyFormatter.Format nodeKeyFormat, java.util.Map<java.net.InetSocketAddress,java.lang.Integer> weights)
Create a KetamaConnectionFactory with the maximum operation queue length, the given read buffer size, the maximum time to block waiting operations, a specific hash algorithm, a set ring key format, and a given set of weights.
-
KetamaConnectionFactory
public KetamaConnectionFactory()
Create a KetamaConnectionFactory with the default parameters.
-
-
Method Detail
-
createLocator
public NodeLocator createLocator(java.util.List<MemcachedNode> nodes)
Description copied from interface:ConnectionFactory
Create a NodeLocator instance for the given list of nodes.- Specified by:
createLocator
in interfaceConnectionFactory
- Overrides:
createLocator
in classDefaultConnectionFactory
-
getKetamaNodeKeyFormat
public KetamaNodeKeyFormatter.Format getKetamaNodeKeyFormat()
- Returns:
- the ketamaNodeKeyFormat
-
getWeights
public java.util.Map<java.net.InetSocketAddress,java.lang.Integer> getWeights()
- Returns:
- the ketama node weights
-
-