com.couchbase.client
Class CouchbaseConnectionFactory

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.DefaultConnectionFactory
          extended by net.spy.memcached.BinaryConnectionFactory
              extended by com.couchbase.client.CouchbaseConnectionFactory
All Implemented Interfaces:
net.spy.memcached.ConnectionFactory

public class CouchbaseConnectionFactory
extends net.spy.memcached.BinaryConnectionFactory

Couchbase implementation of ConnectionFactory.

This implementation creates connections where the operation queue is an ArrayBlockingQueue and the read and write queues are unbounded LinkedBlockingQueues. The Retry FailureMode and KetamaHash VBucket hashing mechanism are always used. If other configurations are needed, look at the ConnectionFactoryBuilder.


Field Summary
protected  ConfigurationProvider configurationProvider
           
static net.spy.memcached.FailureMode DEFAULT_FAILURE_MODE
          Default failure mode.
static net.spy.memcached.HashAlgorithm DEFAULT_HASH
          Default hash algorithm.
static long DEFAULT_MIN_RECONNECT_INTERVAL
          Specify a default minimum reconnect interval of 1.1s.
static long DEFAULT_OBS_POLL_INTERVAL
          Default Observe poll interval in ms.
static int DEFAULT_OBS_POLL_MAX
          Default maximum amount of poll cycles before failure.
static int DEFAULT_OP_QUEUE_LEN
          Maximum length of the operation queue returned by this connection factory.
static int DEFAULT_VIEW_TIMEOUT
          Default View request timeout in ms.
 
Fields inherited from class net.spy.memcached.DefaultConnectionFactory
DEFAULT_MAX_RECONNECT_DELAY, DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD, DEFAULT_OP_QUEUE_MAX_BLOCK_TIME, DEFAULT_OPERATION_TIMEOUT, DEFAULT_READ_BUFFER_SIZE, opQueueLen
 
Constructor Summary
CouchbaseConnectionFactory(java.util.List<java.net.URI> baseList, java.lang.String bucketName, java.lang.String password)
           
 
Method Summary
 net.spy.memcached.MemcachedConnection createConnection(java.util.List<java.net.InetSocketAddress> addrs)
           
 net.spy.memcached.NodeLocator createLocator(java.util.List<net.spy.memcached.MemcachedNode> nodes)
           
 ViewConnection createViewConnection(java.util.List<java.net.InetSocketAddress> addrs)
           
 ViewNode createViewNode(java.net.InetSocketAddress addr, AsyncConnectionManager connMgr)
           
 net.spy.memcached.auth.AuthDescriptor getAuthDescriptor()
           
 java.lang.String getBucketName()
           
 ClusterManager getClusterManager()
          Returns a ClusterManager and initializes one if it does not exist.
 ConfigurationProvider getConfigurationProvider()
           
 Config getVBucketConfig()
           
 int getViewTimeout()
           
protected  boolean pastReconnThreshold()
          Checks if there have been more requests than allowed through maxConfigCheck in a 10 second period.
protected  void requestConfigReconnect(java.lang.String bucketName, Reconfigurable rec)
           
 boolean shouldOptimize()
           
 
Methods inherited from class net.spy.memcached.BinaryConnectionFactory
createMemcachedNode, getName, getOperationFactory
 
Methods inherited from class net.spy.memcached.DefaultConnectionFactory
createOperationQueue, createReadOperationQueue, createWriteOperationQueue, getDefaultTranscoder, getFailureMode, getHashAlg, getInitialObservers, getMaxReconnectDelay, getOperationTimeout, getOpQueueLen, getOpQueueMaxBlockTime, getReadBufSize, getTimeoutExceptionThreshold, isDaemon, toString, useNagleAlgorithm
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FAILURE_MODE

public static final net.spy.memcached.FailureMode DEFAULT_FAILURE_MODE
Default failure mode.


DEFAULT_HASH

public static final net.spy.memcached.HashAlgorithm DEFAULT_HASH
Default hash algorithm.


DEFAULT_OP_QUEUE_LEN

public static final int DEFAULT_OP_QUEUE_LEN
Maximum length of the operation queue returned by this connection factory.

See Also:
Constant Field Values

DEFAULT_MIN_RECONNECT_INTERVAL

public static final long DEFAULT_MIN_RECONNECT_INTERVAL
Specify a default minimum reconnect interval of 1.1s. This means that if a reconnect is needed, it won't try to reconnect more frequently than 1.1s between tries. The initial HTTP connections under us take up to 500ms per request.

See Also:
Constant Field Values

DEFAULT_VIEW_TIMEOUT

public static final int DEFAULT_VIEW_TIMEOUT
Default View request timeout in ms.

See Also:
Constant Field Values

DEFAULT_OBS_POLL_INTERVAL

public static final long DEFAULT_OBS_POLL_INTERVAL
Default Observe poll interval in ms.

See Also:
Constant Field Values

DEFAULT_OBS_POLL_MAX

public static final int DEFAULT_OBS_POLL_MAX
Default maximum amount of poll cycles before failure.

See Also:
Constant Field Values

configurationProvider

protected volatile ConfigurationProvider configurationProvider
Constructor Detail

CouchbaseConnectionFactory

public CouchbaseConnectionFactory(java.util.List<java.net.URI> baseList,
                                  java.lang.String bucketName,
                                  java.lang.String password)
                           throws java.io.IOException
Throws:
java.io.IOException
Method Detail

createViewNode

public ViewNode createViewNode(java.net.InetSocketAddress addr,
                               AsyncConnectionManager connMgr)

createConnection

public net.spy.memcached.MemcachedConnection createConnection(java.util.List<java.net.InetSocketAddress> addrs)
                                                       throws java.io.IOException
Specified by:
createConnection in interface net.spy.memcached.ConnectionFactory
Overrides:
createConnection in class net.spy.memcached.DefaultConnectionFactory
Throws:
java.io.IOException

createViewConnection

public ViewConnection createViewConnection(java.util.List<java.net.InetSocketAddress> addrs)
                                    throws java.io.IOException
Throws:
java.io.IOException

createLocator

public net.spy.memcached.NodeLocator createLocator(java.util.List<net.spy.memcached.MemcachedNode> nodes)
Specified by:
createLocator in interface net.spy.memcached.ConnectionFactory
Overrides:
createLocator in class net.spy.memcached.DefaultConnectionFactory

shouldOptimize

public boolean shouldOptimize()
Specified by:
shouldOptimize in interface net.spy.memcached.ConnectionFactory
Overrides:
shouldOptimize in class net.spy.memcached.DefaultConnectionFactory

getAuthDescriptor

public net.spy.memcached.auth.AuthDescriptor getAuthDescriptor()
Specified by:
getAuthDescriptor in interface net.spy.memcached.ConnectionFactory
Overrides:
getAuthDescriptor in class net.spy.memcached.DefaultConnectionFactory

getBucketName

public java.lang.String getBucketName()

getViewTimeout

public int getViewTimeout()

getVBucketConfig

public Config getVBucketConfig()

getConfigurationProvider

public ConfigurationProvider getConfigurationProvider()

requestConfigReconnect

protected void requestConfigReconnect(java.lang.String bucketName,
                                      Reconfigurable rec)

pastReconnThreshold

protected boolean pastReconnThreshold()
Checks if there have been more requests than allowed through maxConfigCheck in a 10 second period. If this is the case, then true is returned. If the timeframe between two distinct requests is more than 10 seconds, a fresh timeframe starts. This means that 10 calls every second would trigger an update while 1 operation, then a 11 second sleep and one more operation would not.

Returns:
true if there were more config check requests than maxConfigCheck in the 10 second period.

getClusterManager

public ClusterManager getClusterManager()
Returns a ClusterManager and initializes one if it does not exist.

Returns:
Returns an instance of a ClusterManager.


Copyright © 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.