Package net.spy.memcached
Class ConnectionFactoryBuilder
- java.lang.Object
-
- net.spy.memcached.ConnectionFactoryBuilder
-
public class ConnectionFactoryBuilder extends java.lang.Object
Builder for more easily configuring a ConnectionFactory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionFactoryBuilder.Locator
Type of node locator to use.static class
ConnectionFactoryBuilder.Protocol
Type of protocol to use for connections.
-
Field Summary
Fields Modifier and Type Field Description protected AuthDescriptor
authDescriptor
protected long
authWaitTime
protected MetricCollector
collector
protected java.util.concurrent.ExecutorService
executorService
protected FailureMode
failureMode
protected HashAlgorithm
hashAlg
protected java.util.Collection<ConnectionObserver>
initialObservers
protected boolean
isDaemon
protected ConnectionFactoryBuilder.Locator
locator
protected long
maxReconnectDelay
protected MetricType
metricType
protected OperationFactory
opFact
protected OperationQueueFactory
opQueueFactory
protected long
opQueueMaxBlockTime
protected long
opTimeout
protected int
readBufSize
protected OperationQueueFactory
readQueueFactory
protected boolean
shouldOptimize
protected int
timeoutExceptionThreshold
protected Transcoder<java.lang.Object>
transcoder
protected boolean
useNagle
protected OperationQueueFactory
writeQueueFactory
-
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 ConnectionFactory
build()
Get the ConnectionFactory set up with the provided parameters.ConnectionFactoryBuilder
setAuthDescriptor(AuthDescriptor to)
Set the auth descriptor to enable authentication on new connections.ConnectionFactoryBuilder
setAuthWaitTime(long authWaitTime)
Set a custom wait time for the authentication on connect/reconnect.ConnectionFactoryBuilder
setDaemon(boolean d)
Set the daemon state of the IO thread (defaults to true).ConnectionFactoryBuilder
setEnableMetrics(MetricType type)
Enable or disable metric collection.ConnectionFactoryBuilder
setFailureMode(FailureMode fm)
Set the failure mode.ConnectionFactoryBuilder
setHashAlg(HashAlgorithm to)
Set the hash algorithm.ConnectionFactoryBuilder
setInitialObservers(java.util.Collection<ConnectionObserver> obs)
Set the initial connection observers (will observe initial connection).ConnectionFactoryBuilder
setListenerExecutorService(java.util.concurrent.ExecutorService executorService)
Set a customExecutorService
to execute the listener callbacks.ConnectionFactoryBuilder
setLocatorType(ConnectionFactoryBuilder.Locator l)
Set the locator type.ConnectionFactoryBuilder
setMaxReconnectDelay(long to)
Set the maximum reconnect delay.ConnectionFactoryBuilder
setMetricCollector(MetricCollector collector)
Set a customMetricCollector
.ConnectionFactoryBuilder
setOpFact(OperationFactory f)
Set the operation factory.ConnectionFactoryBuilder
setOpQueueFactory(OperationQueueFactory q)
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.ConnectionFactoryBuilder
setOpTimeout(long t)
Set the default operation timeout in milliseconds.ConnectionFactoryBuilder
setProtocol(ConnectionFactoryBuilder.Protocol prot)
Convenience method to specify the protocol to use.ConnectionFactoryBuilder
setReadBufferSize(int to)
Set the read buffer size.ConnectionFactoryBuilder
setReadOpQueueFactory(OperationQueueFactory q)
Set the read queue factory.ConnectionFactoryBuilder
setShouldOptimize(boolean o)
Set to false if the default operation optimization is not desirable.ConnectionFactoryBuilder
setTimeoutExceptionThreshold(int to)
Set the maximum timeout exception threshold.ConnectionFactoryBuilder
setTranscoder(Transcoder<java.lang.Object> t)
Set the default transcoder.ConnectionFactoryBuilder
setUseNagleAlgorithm(boolean to)
Set to true if you'd like to enable the Nagle algorithm.ConnectionFactoryBuilder
setWriteOpQueueFactory(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 customExecutorService
to execute the listener callbacks. Note that if a customExecutorService
is 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.
-
-