Package net.spy.memcached
Interface ConnectionFactory
- All Known Implementing Classes:
BinaryConnectionFactory,DefaultConnectionFactory,KetamaConnectionFactory
public interface ConnectionFactory
Factory for creating instances of MemcachedConnection. This is used to
provide more fine-grained configuration of connections.
-
Method Summary
Modifier and TypeMethodDescriptioncreateConnection(List<InetSocketAddress> addrs) Create a MemcachedConnection for the given SocketAddresses.createLocator(List<MemcachedNode> nodes) Create a NodeLocator instance for the given list of nodes.createMemcachedNode(SocketAddress sa, SocketChannel c, int bufSize) Create a new memcached node.Create a BlockingQueue for operations for a connection.Create a BlockingQueue for the operations currently expecting to read responses from memcached.Create a BlockingQueue for the operations currently expecting to write requests to memcached.If true, metric collections are enabled.Authenticate connections using the given auth descriptor.longThe time to wait until authentication completes when an operation is inserted.The mode in which the client is operating.Get the default transcoder to be used in connections created by this factory.longThe interval used for periodic polling of configuration.Get the default failure mode for the underlying connection.Get the hash algorithm to be used.Get hostname for TLS hostname verification.Observers that should be established at the time of connection instantiation.booleanIf true, keep alive will be used on connected sockets.Get the ExecutorService which is used to asynchronously execute listeners on futures.longMaximum number of milliseconds to wait between reconnect attempts.The currently activeMetricCollector.Get the operation factory for connections built by this connection factory.longGet the operation timeout used by this connection.longGet the maximum amount of time (in milliseconds) a client is willing to wait to add a new item to a queue.intGet SSLContext for TLS connections usage.intMaximum number of timeout exception for shutdown connection.booleanisDaemon()If true, the IO thread should be a daemon thread.booleanReturns true if the default providedExecutorServicehas not been overriden through the builder.voidsetClientMode(ClientMode clientMode) Set the client mode in client.booleanIf true, low-level optimization is in effect.booleanReturns whether or not hostname verification is not required for TLS connection.booleanIf true, the nagle algorithm will be used on connected sockets.
-
Method Details
-
createConnection
Create a MemcachedConnection for the given SocketAddresses.- Parameters:
addrs- the addresses of the memcached servers- Returns:
- a new MemcachedConnection connected to those addresses
- Throws:
IOException- for problems initializing the memcached connections
-
createMemcachedNode
Create a new memcached node. -
createOperationQueue
BlockingQueue<Operation> createOperationQueue()Create a BlockingQueue for operations for a connection. -
createReadOperationQueue
BlockingQueue<Operation> createReadOperationQueue()Create a BlockingQueue for the operations currently expecting to read responses from memcached. -
createWriteOperationQueue
BlockingQueue<Operation> createWriteOperationQueue()Create a BlockingQueue for the operations currently expecting to write requests to memcached. -
getOpQueueMaxBlockTime
long getOpQueueMaxBlockTime()Get the maximum amount of time (in milliseconds) a client is willing to wait to add a new item to a queue. -
getListenerExecutorService
ExecutorService getListenerExecutorService()Get the ExecutorService which is used to asynchronously execute listeners on futures. -
isDefaultExecutorService
boolean isDefaultExecutorService()Returns true if the default providedExecutorServicehas not been overriden through the builder. -
createLocator
Create a NodeLocator instance for the given list of nodes. -
getOperationFactory
OperationFactory getOperationFactory()Get the operation factory for connections built by this connection factory. -
getClientMode
ClientMode getClientMode()The mode in which the client is operating.- Returns:
- the clientMode.
-
setClientMode
Set the client mode in client. Should only be used in the constructor when determine the client mode. -
getDynamicModePollingInterval
long getDynamicModePollingInterval()The interval used for periodic polling of configuration.- Returns:
- the interval in milliseconds
-
getOperationTimeout
long getOperationTimeout()Get the operation timeout used by this connection. -
isDaemon
boolean isDaemon()If true, the IO thread should be a daemon thread. -
useNagleAlgorithm
boolean useNagleAlgorithm()If true, the nagle algorithm will be used on connected sockets.See
Socket.setTcpNoDelay(boolean)for more information. -
getKeepAlive
boolean getKeepAlive()If true, keep alive will be used on connected sockets.See
Socket.setKeepAlive(boolean)for more information. -
getInitialObservers
Collection<ConnectionObserver> getInitialObservers()Observers that should be established at the time of connection instantiation. These observers will see the first connection established. -
getFailureMode
FailureMode getFailureMode()Get the default failure mode for the underlying connection. -
getDefaultTranscoder
Transcoder<Object> getDefaultTranscoder()Get the default transcoder to be used in connections created by this factory. -
shouldOptimize
boolean shouldOptimize()If true, low-level optimization is in effect. -
getReadBufSize
int getReadBufSize() -
getHashAlg
HashAlgorithm getHashAlg()Get the hash algorithm to be used. -
getMaxReconnectDelay
long getMaxReconnectDelay()Maximum number of milliseconds to wait between reconnect attempts. -
getAuthDescriptor
AuthDescriptor getAuthDescriptor()Authenticate connections using the given auth descriptor.- Returns:
- null if no authentication should take place
-
getTimeoutExceptionThreshold
int getTimeoutExceptionThreshold()Maximum number of timeout exception for shutdown connection. -
enableMetrics
MetricType enableMetrics()If true, metric collections are enabled. -
getMetricCollector
MetricCollector getMetricCollector()The currently activeMetricCollector. -
getAuthWaitTime
long getAuthWaitTime()The time to wait until authentication completes when an operation is inserted.- Returns:
- the time in milliseconds.
-
getSSLContext
SSLContext getSSLContext()Get SSLContext for TLS connections usage.- Returns:
- the SSLContext for TLS connections, null for non-TLS connections.
-
getHostnameForTlsVerification
String getHostnameForTlsVerification()Get hostname for TLS hostname verification.- Returns:
- hostname for TLS hostname verification, null if TLS hostname verification disabled.
-
skipTlsHostnameVerification
boolean skipTlsHostnameVerification()Returns whether or not hostname verification is not required for TLS connection.- Returns:
- false if require hostname verification, true if not require hostname verification.
-