From 424df087f9256b85e7b3a9b31d36518081ff2875 Mon Sep 17 00:00:00 2001 From: Greg Studer Date: Thu, 5 Jul 2012 15:05:10 -0400 Subject: SERVER-6282 wait-doubling backoff for local mongos errors requiring config server access --- src/mongo/util/time_support.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/mongo/util/time_support.h') diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h index 511bc092fb1..254401b01ad 100644 --- a/src/mongo/util/time_support.h +++ b/src/mongo/util/time_support.h @@ -43,6 +43,29 @@ namespace mongo { void sleepmillis(long long ms); void sleepmicros(long long micros); + class Backoff { + public: + + Backoff( int maxSleepMillis, int resetAfter ) : + _maxSleepMillis( maxSleepMillis ), + _resetAfterMillis( maxSleepMillis + resetAfter ), // Don't reset < the max sleep + _lastSleepMillis( 0 ), + _lastErrorTimeMillis( 0 ) + {} + + void nextSleepMillis(); + + private: + + // Parameters + int _maxSleepMillis; + int _resetAfterMillis; + + // Last sleep information + int _lastSleepMillis; + unsigned long long _lastErrorTimeMillis; + }; + // DO NOT TOUCH except for testing void jsTimeVirtualSkew( long long skew ); -- cgit v1.2.1