public class DefaultConnectionFactory extends SpyObject implements ConnectionFactory
This implementation creates connections where the operation queue is an
ArrayBlockingQueue and the read and write queues are unbounded
LinkedBlockingQueues. The Redistribute FailureMode is always
used. If other FailureModes are needed, look at the ConnectionFactoryBuilder.
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_AUTH_WAIT_TIME
The time to wait for the authentication to complete when a operation
is written in milliseconds.
|
static ClientMode |
DEFAULT_CLIENT_MODE
Default client mode.
|
static FailureMode |
DEFAULT_FAILURE_MODE
Default failure mode.
|
static HashAlgorithm |
DEFAULT_HASH
Default hash algorithm.
|
static long |
DEFAULT_MAX_RECONNECT_DELAY
Maximum amount of time (in seconds) to wait between reconnect attempts.
|
static int |
DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
Maximum number + 2 of timeout exception for shutdown connection.
|
static MetricType |
DEFAULT_METRIC_TYPE
Turn off metric collection by default.
|
static int |
DEFAULT_OP_QUEUE_LEN
Maximum length of the operation queue returned by this connection factory.
|
static long |
DEFAULT_OP_QUEUE_MAX_BLOCK_TIME
The maximum time to block waiting for op queue operations to complete, in
milliseconds.
|
static long |
DEFAULT_OPERATION_TIMEOUT
Default operation timeout in milliseconds.
|
static int |
DEFAULT_READ_BUFFER_SIZE
The read buffer size for each server connection from this factory.
|
protected int |
opQueueLen |
| Constructor and Description |
|---|
DefaultConnectionFactory() |
DefaultConnectionFactory(ClientMode clientMode)
Create a DefaultConnectionFactory with the default parameters.
|
DefaultConnectionFactory(ClientMode clientMode,
int qLen,
int bufSize)
Create a DefaultConnectionFactory with the given maximum operation queue
length, and the given read buffer size.
|
DefaultConnectionFactory(ClientMode clientMode,
int qLen,
int bufSize,
HashAlgorithm hash)
Construct a DefaultConnectionFactory with the given parameters.
|
DefaultConnectionFactory(int qLen,
int bufSize)
Create a DefaultConnectionFactory with the given maximum operation queue
length, and the given read buffer size.
|
DefaultConnectionFactory(int qLen,
int bufSize,
HashAlgorithm hash)
Construct a DefaultConnectionFactory with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
MemcachedConnection |
createConnection(java.util.List<java.net.InetSocketAddress> addrs)
Create a MemcachedConnection for the given SocketAddresses.
|
NodeLocator |
createLocator(java.util.List<MemcachedNode> nodes)
Create a NodeLocator instance for the given list of nodes.
|
MemcachedNode |
createMemcachedNode(java.net.SocketAddress sa,
java.nio.channels.SocketChannel c,
int bufSize)
Create a new memcached node.
|
java.util.concurrent.BlockingQueue<Operation> |
createOperationQueue()
Create a BlockingQueue for operations for a connection.
|
java.util.concurrent.BlockingQueue<Operation> |
createReadOperationQueue()
Create a BlockingQueue for the operations currently expecting to read
responses from memcached.
|
java.util.concurrent.BlockingQueue<Operation> |
createWriteOperationQueue()
Create a BlockingQueue for the operations currently expecting to write
requests to memcached.
|
MetricType |
enableMetrics()
If true, metric collections are enabled.
|
AuthDescriptor |
getAuthDescriptor()
Authenticate connections using the given auth descriptor.
|
long |
getAuthWaitTime()
The time to wait until authentication completes when an operation is
inserted.
|
ClientMode |
getClientMode()
The mode in which the client is operating.
|
Transcoder<java.lang.Object> |
getDefaultTranscoder()
Get the default transcoder to be used in connections created by this
factory.
|
long |
getDynamicModePollingInterval()
The interval used for periodic polling of configuration.
|
FailureMode |
getFailureMode()
Get the default failure mode for the underlying connection.
|
HashAlgorithm |
getHashAlg()
Get the hash algorithm to be used.
|
java.lang.String |
getHostnameForTlsVerification()
Get hostname for hostname verification.
|
java.util.Collection<ConnectionObserver> |
getInitialObservers()
Observers that should be established at the time of connection
instantiation.
|
boolean |
getKeepAlive()
If true, keep alive will be used on connected sockets.
|
java.util.concurrent.ExecutorService |
getListenerExecutorService()
Returns the stored
ExecutorService for listeners. |
long |
getMaxReconnectDelay()
Maximum number of milliseconds to wait between reconnect attempts.
|
MetricCollector |
getMetricCollector()
The currently active
MetricCollector. |
protected java.lang.String |
getName() |
OperationFactory |
getOperationFactory()
Get the operation factory for connections built by this connection factory.
|
long |
getOperationTimeout()
Get the operation timeout used by this connection.
|
int |
getOpQueueLen()
Get the op queue length set at construct time.
|
long |
getOpQueueMaxBlockTime()
Get the maximum amount of time (in milliseconds) a client is willing to
wait to add a new item to a queue.
|
int |
getReadBufSize() |
javax.net.ssl.SSLContext |
getSSLContext()
Get SSLContext for TLS connections usage.
|
int |
getTimeoutExceptionThreshold()
Maximum number of timeout exception for shutdown connection.
|
boolean |
isDaemon()
If true, the IO thread should be a daemon thread.
|
boolean |
isDefaultExecutorService()
Returns true if the default provided
ExecutorService has not been
overriden through the builder. |
void |
setClientMode(ClientMode clientMode)
Set the client mode in client.
|
boolean |
shouldOptimize()
If true, low-level optimization is in effect.
|
boolean |
skipTlsHostnameVerification()
Returns whether or not hostname verification is not required for TLS connection (default to false).
|
java.lang.String |
toString() |
boolean |
useNagleAlgorithm()
If true, the nagle algorithm will be used on connected sockets.
|
public static final ClientMode DEFAULT_CLIENT_MODE
public static final FailureMode DEFAULT_FAILURE_MODE
public static final HashAlgorithm DEFAULT_HASH
public static final int DEFAULT_OP_QUEUE_LEN
public static final long DEFAULT_OP_QUEUE_MAX_BLOCK_TIME
public static final int DEFAULT_READ_BUFFER_SIZE
public static final long DEFAULT_OPERATION_TIMEOUT
public static final long DEFAULT_MAX_RECONNECT_DELAY
public static final int DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
public static final MetricType DEFAULT_METRIC_TYPE
public static final long DEFAULT_AUTH_WAIT_TIME
protected final int opQueueLen
public DefaultConnectionFactory(ClientMode clientMode, int qLen, int bufSize, HashAlgorithm hash)
clientMode - the client mode.qLen - the queue length.bufSize - the buffer sizehash - the algorithm to use for hashingpublic DefaultConnectionFactory(int qLen,
int bufSize,
HashAlgorithm hash)
qLen - the queue length.bufSize - the buffer sizehash - the algorithm to use for hashingpublic DefaultConnectionFactory(ClientMode clientMode, int qLen, int bufSize)
public DefaultConnectionFactory(int qLen,
int bufSize)
public DefaultConnectionFactory(ClientMode clientMode)
public DefaultConnectionFactory()
public ClientMode getClientMode()
ConnectionFactorygetClientMode in interface ConnectionFactorypublic void setClientMode(ClientMode clientMode)
ConnectionFactorysetClientMode in interface ConnectionFactorypublic long getDynamicModePollingInterval()
ConnectionFactorygetDynamicModePollingInterval in interface ConnectionFactorypublic MemcachedNode createMemcachedNode(java.net.SocketAddress sa, java.nio.channels.SocketChannel c, int bufSize)
ConnectionFactorycreateMemcachedNode in interface ConnectionFactorypublic MemcachedConnection createConnection(java.util.List<java.net.InetSocketAddress> addrs) throws java.io.IOException
ConnectionFactorycreateConnection in interface ConnectionFactoryaddrs - the addresses of the memcached serversjava.io.IOException - for problems initializing the memcached connectionspublic FailureMode getFailureMode()
ConnectionFactorygetFailureMode in interface ConnectionFactorypublic java.util.concurrent.BlockingQueue<Operation> createOperationQueue()
ConnectionFactorycreateOperationQueue in interface ConnectionFactorypublic java.util.concurrent.BlockingQueue<Operation> createReadOperationQueue()
ConnectionFactorycreateReadOperationQueue in interface ConnectionFactorypublic java.util.concurrent.BlockingQueue<Operation> createWriteOperationQueue()
ConnectionFactorycreateWriteOperationQueue in interface ConnectionFactorypublic NodeLocator createLocator(java.util.List<MemcachedNode> nodes)
ConnectionFactorycreateLocator in interface ConnectionFactorypublic int getOpQueueLen()
public long getOpQueueMaxBlockTime()
ConnectionFactorygetOpQueueMaxBlockTime in interface ConnectionFactorypublic long getAuthWaitTime()
ConnectionFactorygetAuthWaitTime in interface ConnectionFactorypublic java.util.concurrent.ExecutorService getListenerExecutorService()
ExecutorService for listeners.
By default, a ThreadPoolExecutor is used that acts exactly
like a default cachedThreadPool, but defines the upper limit of
Threads to be created as the number of available processors to
prevent resource exhaustion.getListenerExecutorService in interface ConnectionFactoryExecutorService.public boolean isDefaultExecutorService()
ConnectionFactoryExecutorService has not been
overriden through the builder.isDefaultExecutorService in interface ConnectionFactorypublic int getReadBufSize()
getReadBufSize in interface ConnectionFactorypublic HashAlgorithm getHashAlg()
ConnectionFactorygetHashAlg in interface ConnectionFactorypublic OperationFactory getOperationFactory()
ConnectionFactorygetOperationFactory in interface ConnectionFactorypublic long getOperationTimeout()
ConnectionFactorygetOperationTimeout in interface ConnectionFactorypublic boolean isDaemon()
ConnectionFactoryisDaemon in interface ConnectionFactorypublic java.util.Collection<ConnectionObserver> getInitialObservers()
ConnectionFactorygetInitialObservers in interface ConnectionFactorypublic Transcoder<java.lang.Object> getDefaultTranscoder()
ConnectionFactorygetDefaultTranscoder in interface ConnectionFactorypublic boolean useNagleAlgorithm()
ConnectionFactory
See Socket.setTcpNoDelay(boolean) for more information.
useNagleAlgorithm in interface ConnectionFactorypublic boolean getKeepAlive()
ConnectionFactory
See Socket.setKeepAlive(boolean) for more information.
getKeepAlive in interface ConnectionFactorypublic boolean shouldOptimize()
ConnectionFactoryshouldOptimize in interface ConnectionFactorypublic long getMaxReconnectDelay()
ConnectionFactorygetMaxReconnectDelay in interface ConnectionFactorypublic AuthDescriptor getAuthDescriptor()
ConnectionFactorygetAuthDescriptor in interface ConnectionFactorypublic int getTimeoutExceptionThreshold()
ConnectionFactorygetTimeoutExceptionThreshold in interface ConnectionFactorypublic javax.net.ssl.SSLContext getSSLContext()
getSSLContext in interface ConnectionFactorypublic java.lang.String getHostnameForTlsVerification()
getHostnameForTlsVerification in interface ConnectionFactorypublic boolean skipTlsHostnameVerification()
skipTlsHostnameVerification in interface ConnectionFactorypublic MetricType enableMetrics()
ConnectionFactoryenableMetrics in interface ConnectionFactorypublic MetricCollector getMetricCollector()
ConnectionFactoryMetricCollector.getMetricCollector in interface ConnectionFactoryprotected java.lang.String getName()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.