AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.4.3
AMPS::ExponentialDelayStrategy Class Reference

ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, with a maximum number of retries before it gives up entirely. More...

#include <ReconnectDelayStrategyImpl.hpp>

+ Inheritance diagram for AMPS::ExponentialDelayStrategy:

Public Member Functions

 ExponentialDelayStrategy (unsigned int initialDelay_=200, unsigned int maximumDelay_=20 *1000, double backoffExponent_=2.0, unsigned int maximumRetryTime_=0, double jitter_=1.0)
 Constructs an exponential delay strategy, the default strategy for HAClient. More...
 
unsigned int getConnectWaitDuration (const std::string &uri_)
 Returns the time that the client should delay before connecting to the given server URI. More...
 
void reset (void)
 Reset the state of this reconnect delay. More...
 

Detailed Description

ExponentialDelayStrategy is an implementation that exponentially "backs off" when reconnecting to the same server, with a maximum number of retries before it gives up entirely.

Constructor & Destructor Documentation

AMPS::ExponentialDelayStrategy::ExponentialDelayStrategy ( unsigned int  initialDelay_ = 200,
unsigned int  maximumDelay_ = 20 * 1000,
double  backoffExponent_ = 2.0,
unsigned int  maximumRetryTime_ = 0,
double  jitter_ = 1.0 
)
inline

Constructs an exponential delay strategy, the default strategy for HAClient.

Parameters
initialDelay_The time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection attempt.
maximumDelay_The maximum time to wait for any reconnect attempt (milliseconds). Exponential backoff will not exceed this maximum.
backoffExponent_The exponent to use for calculating the next delay time. For example, if the initial time is 200ms and the exponent is 2.0, the next delay will be 400ms, then 800ms, etc.
maximumRetryTime_The maximum time (milliseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt.
jitter_The amount of 'jitter' to apply when calculating a delay time, measured in multiples of the initial delay. Jitter is used to reduce the number of simultaneous reconnects that may be issued from multiple clients.

Member Function Documentation

unsigned int AMPS::ExponentialDelayStrategy::getConnectWaitDuration ( const std::string &  uri_)
inlinevirtual

Returns the time that the client should delay before connecting to the given server URI.

Parameters
uri_The URI which the client plans to connect.
Returns
The time, in milliseconds, which the client should delay before connecting to uri_.
Exceptions
Anyexception thrown indicates no connection should be attempted; the client should in essence "give up."

Implements AMPS::ReconnectDelayStrategyImpl.

void AMPS::ExponentialDelayStrategy::reset ( void  )
inlinevirtual

Reset the state of this reconnect delay.

AMPS calls this method when a connection is successfully established.

Implements AMPS::ReconnectDelayStrategyImpl.


The documentation for this class was generated from the following file: