Package net.spy.memcached
Class ConnectionFactoryBuilder
- java.lang.Object
-
- net.spy.memcached.ConnectionFactoryBuilder
-
public class ConnectionFactoryBuilder extends java.lang.ObjectBuilder for more easily configuring a ConnectionFactory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnectionFactoryBuilder.LocatorType of node locator to use.static classConnectionFactoryBuilder.ProtocolType of protocol to use for connections.
-
Field Summary
Fields Modifier and Type Field Description protected AuthDescriptorauthDescriptorprotected longauthWaitTimeprotected MetricCollectorcollectorprotected java.util.concurrent.ExecutorServiceexecutorServiceprotected FailureModefailureModeprotected HashAlgorithmhashAlgprotected java.util.Collection<ConnectionObserver>initialObserversprotected booleanisDaemonprotected ConnectionFactoryBuilder.Locatorlocatorprotected longmaxReconnectDelayprotected MetricTypemetricTypeprotected OperationFactoryopFactprotected OperationQueueFactoryopQueueFactoryprotected longopQueueMaxBlockTimeprotected longopTimeoutprotected intreadBufSizeprotected OperationQueueFactoryreadQueueFactoryprotected booleanshouldOptimizeprotected inttimeoutExceptionThresholdprotected Transcoder<java.lang.Object>transcoderprotected booleanuseNagleprotected OperationQueueFactorywriteQueueFactory
-
Constructor Summary
Constructors Constructor Description ConnectionFactoryBuilder()Set the operation queue factory.ConnectionFactoryBuilder(ConnectionFactory cf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectionFactorybuild()Get the ConnectionFactory set up with the provided parameters.ConnectionFactoryBuildersetAuthDescriptor(AuthDescriptor to)Set the auth descriptor to enable authentication on new connections.ConnectionFactoryBuildersetAuthWaitTime(long authWaitTime)Set a custom wait time for the authentication on connect/reconnect.ConnectionFactoryBuildersetDaemon(boolean d)Set the daemon state of the IO thread (defaults to true).ConnectionFactoryBuildersetEnableMetrics(MetricType type)Enable or disable metric collection.ConnectionFactoryBuildersetFailureMode(FailureMode fm)Set the failure mode.ConnectionFactoryBuildersetHashAlg(HashAlgorithm to)Set the hash algorithm.ConnectionFactoryBuildersetInitialObservers(java.util.Collection<ConnectionObserver> obs)Set the initial connection observers (will observe initial connection).ConnectionFactoryBuildersetListenerExecutorService(java.util.concurrent.ExecutorService executorService)Set a customExecutorServiceto execute the listener callbacks.ConnectionFactoryBuildersetLocatorType(ConnectionFactoryBuilder.Locator l)Set the locator type.ConnectionFactoryBuildersetMaxReconnectDelay(long to)Set the maximum reconnect delay.ConnectionFactoryBuildersetMetricCollector(MetricCollector collector)Set a customMetricCollector.ConnectionFactoryBuildersetOpFact(OperationFactory f)Set the operation factory.ConnectionFactoryBuildersetOpQueueFactory(OperationQueueFactory q)ConnectionFactoryBuildersetOpQueueMaxBlockTime(long t)Set the maximum amount of time (in milliseconds) a client is willing to wait for space to become available in an output queue.ConnectionFactoryBuildersetOpTimeout(long t)Set the default operation timeout in milliseconds.ConnectionFactoryBuildersetProtocol(ConnectionFactoryBuilder.Protocol prot)Convenience method to specify the protocol to use.ConnectionFactoryBuildersetReadBufferSize(int to)Set the read buffer size.ConnectionFactoryBuildersetReadOpQueueFactory(OperationQueueFactory q)Set the read queue factory.ConnectionFactoryBuildersetShouldOptimize(boolean o)Set to false if the default operation optimization is not desirable.ConnectionFactoryBuildersetTimeoutExceptionThreshold(int to)Set the maximum timeout exception threshold.ConnectionFactoryBuildersetTranscoder(Transcoder<java.lang.Object> t)Set the default transcoder.ConnectionFactoryBuildersetUseNagleAlgorithm(boolean to)Set to true if you'd like to enable the Nagle algorithm.ConnectionFactoryBuildersetWriteOpQueueFactory(OperationQueueFactory q)Set the write queue factory.
-
-
-
Field Detail
-
opQueueFactory
protected OperationQueueFactory opQueueFactory
-
readQueueFactory
protected OperationQueueFactory readQueueFactory
-
writeQueueFactory
protected OperationQueueFactory writeQueueFactory
-
transcoder
protected Transcoder<java.lang.Object> transcoder
-
failureMode
protected FailureMode failureMode
-
initialObservers
protected java.util.Collection<ConnectionObserver> initialObservers
-
opFact
protected OperationFactory opFact
-
locator
protected ConnectionFactoryBuilder.Locator locator
-
opTimeout
protected long opTimeout
-
isDaemon
protected boolean isDaemon
-
shouldOptimize
protected boolean shouldOptimize
-
useNagle
protected boolean useNagle
-
maxReconnectDelay
protected long maxReconnectDelay
-
readBufSize
protected int readBufSize
-
hashAlg
protected HashAlgorithm hashAlg
-
authDescriptor
protected AuthDescriptor authDescriptor
-
opQueueMaxBlockTime
protected long opQueueMaxBlockTime
-
timeoutExceptionThreshold
protected int timeoutExceptionThreshold
-
metricType
protected MetricType metricType
-
collector
protected MetricCollector collector
-
executorService
protected java.util.concurrent.ExecutorService executorService
-
authWaitTime
protected long authWaitTime
-
-
Constructor Detail
-
ConnectionFactoryBuilder
public ConnectionFactoryBuilder()
Set the operation queue factory.
-
ConnectionFactoryBuilder
public ConnectionFactoryBuilder(ConnectionFactory cf)
-
-
Method Detail
-
setOpQueueFactory
public ConnectionFactoryBuilder setOpQueueFactory(OperationQueueFactory q)
-
setReadOpQueueFactory
public ConnectionFactoryBuilder setReadOpQueueFactory(OperationQueueFactory q)
Set the read queue factory.
-
setWriteOpQueueFactory
public ConnectionFactoryBuilder setWriteOpQueueFactory(OperationQueueFactory q)
Set the write queue factory.
-
setOpQueueMaxBlockTime
public ConnectionFactoryBuilder setOpQueueMaxBlockTime(long t)
Set the maximum amount of time (in milliseconds) a client is willing to wait for space to become available in an output queue.
-
setTranscoder
public ConnectionFactoryBuilder setTranscoder(Transcoder<java.lang.Object> t)
Set the default transcoder.
-
setFailureMode
public ConnectionFactoryBuilder setFailureMode(FailureMode fm)
Set the failure mode.
-
setInitialObservers
public ConnectionFactoryBuilder setInitialObservers(java.util.Collection<ConnectionObserver> obs)
Set the initial connection observers (will observe initial connection).
-
setOpFact
public ConnectionFactoryBuilder setOpFact(OperationFactory f)
Set the operation factory. Note that the operation factory is used to also imply the type of nodes to create.- See Also:
MemcachedNode
-
setOpTimeout
public ConnectionFactoryBuilder setOpTimeout(long t)
Set the default operation timeout in milliseconds.
-
setDaemon
public ConnectionFactoryBuilder setDaemon(boolean d)
Set the daemon state of the IO thread (defaults to true).
-
setShouldOptimize
public ConnectionFactoryBuilder setShouldOptimize(boolean o)
Set to false if the default operation optimization is not desirable.
-
setReadBufferSize
public ConnectionFactoryBuilder setReadBufferSize(int to)
Set the read buffer size.
-
setHashAlg
public ConnectionFactoryBuilder setHashAlg(HashAlgorithm to)
Set the hash algorithm.
-
setUseNagleAlgorithm
public ConnectionFactoryBuilder setUseNagleAlgorithm(boolean to)
Set to true if you'd like to enable the Nagle algorithm.
-
setProtocol
public ConnectionFactoryBuilder setProtocol(ConnectionFactoryBuilder.Protocol prot)
Convenience method to specify the protocol to use.
-
setLocatorType
public ConnectionFactoryBuilder setLocatorType(ConnectionFactoryBuilder.Locator l)
Set the locator type.
-
setMaxReconnectDelay
public ConnectionFactoryBuilder setMaxReconnectDelay(long to)
Set the maximum reconnect delay.
-
setAuthDescriptor
public ConnectionFactoryBuilder setAuthDescriptor(AuthDescriptor to)
Set the auth descriptor to enable authentication on new connections.
-
setTimeoutExceptionThreshold
public ConnectionFactoryBuilder setTimeoutExceptionThreshold(int to)
Set the maximum timeout exception threshold.
-
setEnableMetrics
public ConnectionFactoryBuilder setEnableMetrics(MetricType type)
Enable or disable metric collection.- Parameters:
type- the metric type to use (or disable).
-
setMetricCollector
public ConnectionFactoryBuilder setMetricCollector(MetricCollector collector)
Set a customMetricCollector.- Parameters:
collector- the metric collector to use.
-
setListenerExecutorService
public ConnectionFactoryBuilder setListenerExecutorService(java.util.concurrent.ExecutorService executorService)
Set a customExecutorServiceto execute the listener callbacks. Note that if a customExecutorServiceis passed in, it also needs to be properly shut down by the caller. The library itself treats it as a outside managed resource. Therefore, also make sure to not shut it down before all instances that use it are shut down.- Parameters:
executorService- the ExecutorService to use.
-
setAuthWaitTime
public ConnectionFactoryBuilder setAuthWaitTime(long authWaitTime)
Set a custom wait time for the authentication on connect/reconnect.- Parameters:
authWaitTime- the time in milliseconds.
-
build
public ConnectionFactory build()
Get the ConnectionFactory set up with the provided parameters.
-
-