Class DefaultConnectionFactory

java.lang.Object
net.spy.memcached.compat.SpyObject
net.spy.memcached.DefaultConnectionFactory
All Implemented Interfaces:
ConnectionFactory
Direct Known Subclasses:
BinaryConnectionFactory, KetamaConnectionFactory

public class DefaultConnectionFactory extends SpyObject implements ConnectionFactory
Default implementation of ConnectionFactory.

This implementation creates connections where the operation queue is an ArrayBlockingQueue and the read and write queues are unbounded LinkedBlockingQueues. The Redistribute FailureMode is always used. If other FailureModes are needed, look at the ConnectionFactoryBuilder.

  • Field Details

    • DEFAULT_FAILURE_MODE

      public static final FailureMode DEFAULT_FAILURE_MODE
      Default failure mode.
    • DEFAULT_HASH

      public static final 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:
    • DEFAULT_OP_QUEUE_MAX_BLOCK_TIME

      public static final long DEFAULT_OP_QUEUE_MAX_BLOCK_TIME
      The maximum time to block waiting for op queue operations to complete, in milliseconds. The default has been set with the expectation that most requests are interactive and waiting for more than a few seconds is thus more undesirable than failing the request.
    • DEFAULT_READ_BUFFER_SIZE

      public static final int DEFAULT_READ_BUFFER_SIZE
      The read buffer size for each server connection from this factory.
      See Also:
    • DEFAULT_OPERATION_TIMEOUT

      public static final long DEFAULT_OPERATION_TIMEOUT
      Default operation timeout in milliseconds.
      See Also:
    • DEFAULT_MAX_RECONNECT_DELAY

      public static final long DEFAULT_MAX_RECONNECT_DELAY
      Maximum amount of time (in seconds) to wait between reconnect attempts.
      See Also:
    • DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD

      public static final int DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
      Maximum number + 2 of timeout exception for shutdown connection.
      See Also:
    • DEFAULT_METRIC_TYPE

      public static final MetricType DEFAULT_METRIC_TYPE
      Turn off metric collection by default.
    • DEFAULT_AUTH_WAIT_TIME

      public static final long DEFAULT_AUTH_WAIT_TIME
      The time to wait for the authentication to complete when a operation is written in milliseconds.
      See Also:
    • opQueueLen

      protected final int opQueueLen
    • readBufSize

      private final int readBufSize
    • hashAlg

      private final HashAlgorithm hashAlg
    • metrics

      private MetricCollector metrics
    • executorService

      private ExecutorService executorService
      The ExecutorService in which the listener callbacks will be executed.
  • Constructor Details

    • DefaultConnectionFactory

      public DefaultConnectionFactory(int qLen, int bufSize, HashAlgorithm hash)
      Construct a DefaultConnectionFactory with the given parameters.
      Parameters:
      qLen - the queue length.
      bufSize - the buffer size
      hash - the algorithm to use for hashing
    • DefaultConnectionFactory

      public DefaultConnectionFactory(int qLen, int bufSize)
      Create a DefaultConnectionFactory with the given maximum operation queue length, and the given read buffer size.
    • DefaultConnectionFactory

      public DefaultConnectionFactory()
      Create a DefaultConnectionFactory with the default parameters.
  • Method Details