net.spy.memcached
Class ConnectionFactoryBuilder

java.lang.Object
  extended by net.spy.memcached.ConnectionFactoryBuilder

public class ConnectionFactoryBuilder
extends Object

Builder for more easily configuring a ConnectionFactory.


Nested Class Summary
static class ConnectionFactoryBuilder.Locator
          Type of node locator to use.
static class ConnectionFactoryBuilder.Protocol
          Type of protocol to use for connections.
 
Constructor Summary
ConnectionFactoryBuilder()
          Set the operation queue factory.
ConnectionFactoryBuilder(ConnectionFactory cf)
           
 
Method Summary
 ConnectionFactory build()
          Get the ConnectionFactory set up with the provided parameters.
 MembaseConnectionFactory buildMembaseConnection(List<URI> baseList, String bucketName, String usr, String pwd)
          Get the MembaseConnectionFactory set up with the provided parameters.
 Config getVBucketConfig()
           
 ConnectionFactoryBuilder setAuthDescriptor(AuthDescriptor to)
          Set the auth descriptor to enable authentication on new connections.
 ConnectionFactoryBuilder setDaemon(boolean d)
          Set the daemon state of the IO thread (defaults to true).
 ConnectionFactoryBuilder setFailureMode(FailureMode fm)
          Set the failure mode.
 ConnectionFactoryBuilder setHashAlg(HashAlgorithm to)
          Set the hash algorithm.
 ConnectionFactoryBuilder setInitialObservers(Collection<ConnectionObserver> obs)
          Set the initial connection observers (will observe initial connection).
 ConnectionFactoryBuilder setLocatorType(ConnectionFactoryBuilder.Locator l)
          Set the locator type.
 ConnectionFactoryBuilder setMaxReconnectDelay(long to)
          Set the maximum reconnect delay.
 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<Object> t)
          Set the default transcoder.
 ConnectionFactoryBuilder setUseNagleAlgorithm(boolean to)
          Set to true if you'd like to enable the Nagle algorithm.
 void setVBucketConfig(Config vBucketConfig)
           
 ConnectionFactoryBuilder setWriteOpQueueFactory(OperationQueueFactory q)
          Set the write queue factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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<Object> t)
Set the default transcoder.


setFailureMode

public ConnectionFactoryBuilder setFailureMode(FailureMode fm)
Set the failure mode.


setInitialObservers

public ConnectionFactoryBuilder setInitialObservers(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


getVBucketConfig

public Config getVBucketConfig()

setVBucketConfig

public void setVBucketConfig(Config vBucketConfig)

build

public ConnectionFactory build()
Get the ConnectionFactory set up with the provided parameters.


buildMembaseConnection

public MembaseConnectionFactory buildMembaseConnection(List<URI> baseList,
                                                       String bucketName,
                                                       String usr,
                                                       String pwd)
                                                throws IOException
Get the MembaseConnectionFactory set up with the provided parameters. Note that a MembaseConnectionFactory requires the failure mode is set to retry, and the locator type is discovered dynamically based on the cluster you are connecting to. As a result, these values will be overridden upon calling this function.

Parameters:
baseList - a list of URI's that will be used to connect to the cluster
bucketName - the name of the bucket to connect to
usr - the username for the bucket
pwd - the password for the bucket
Returns:
a MembaseConnectionFactory object
Throws:
IOException