com.couchbase.client.internal
Class AdaptiveThrottler

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by com.couchbase.client.internal.AdaptiveThrottler
All Implemented Interfaces:
Throttler

public class AdaptiveThrottler
extends net.spy.memcached.compat.SpyObject
implements Throttler

The AdaptiveThrottler allows dynamic backoff of memcached operations to make sure the server is not overloaded to more then a certain level.


Constructor Summary
AdaptiveThrottler(CouchbaseConnection conn, net.spy.memcached.protocol.binary.BinaryOperationFactory opFact, java.net.InetSocketAddress node)
          Initialize the Throttler with sensible default settings.
AdaptiveThrottler(CouchbaseConnection conn, net.spy.memcached.protocol.binary.BinaryOperationFactory opFact, java.net.InetSocketAddress node, int normalStatsInterval, int highStatsInterval, int criticalStatsInterval, int highSleep, int criticalSleep)
          Construct the AdaptiveThrottler with all possible options.
 
Method Summary
 void throttle()
          Throttle if needed based on the given throttle constraints.
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptiveThrottler

public AdaptiveThrottler(CouchbaseConnection conn,
                         net.spy.memcached.protocol.binary.BinaryOperationFactory opFact,
                         java.net.InetSocketAddress node)
Initialize the Throttler with sensible default settings. Also, when the appropriate property settings are loaded (see the CouchbaseProperties class for more information), those will be used instead of the default settings. Note that there is a second constructor available that lets you set all properties by hand. These are the default settings: - Normal Stats Interval Check: 10000 operations (normalStatsInterval) - High Stats Interval Check: 100 operations (highStatsInterval) - Critical Stats Interval Check: 10 operations (criticalStatsInterval) - Time of throttle when High: 1ms (high_sleep_time) - Time of throttle when critical: 3ms (critical_sleep_time)


AdaptiveThrottler

public AdaptiveThrottler(CouchbaseConnection conn,
                         net.spy.memcached.protocol.binary.BinaryOperationFactory opFact,
                         java.net.InetSocketAddress node,
                         int normalStatsInterval,
                         int highStatsInterval,
                         int criticalStatsInterval,
                         int highSleep,
                         int criticalSleep)
Construct the AdaptiveThrottler with all possible options.

Parameters:
conn - the CouchbaseConnection to work against.
opFact - the BinaryOperationFactory to work against.
node - the node for the throttler.
normalStatsInterval - After how many operations a check should be initialized when memory is below high_wat.
highStatsInterval - After how many operations a check should be initialized when memory is higher than high_wat (< 10%)
criticalStatsInterval - After how many operations a check should be initialized when memory is higher than high_wat (> 10%)
highSleep - The time (in ms) to throttle when high is reached.
criticalSleep - The time (in ms) to throttle when critical is reached.
Method Detail

throttle

public void throttle()
Throttle if needed based on the given throttle constraints.

Specified by:
throttle in interface Throttler


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