org.apache.curator.retry
Class BoundedExponentialBackoffRetry

java.lang.Object
  extended by org.apache.curator.retry.ExponentialBackoffRetry
      extended by org.apache.curator.retry.BoundedExponentialBackoffRetry
All Implemented Interfaces:
RetryPolicy

public class BoundedExponentialBackoffRetry
extends ExponentialBackoffRetry

Retry policy that retries a set number of times with an increasing (up to a maximum bound) sleep time between retries


Constructor Summary
BoundedExponentialBackoffRetry(int baseSleepTimeMs, int maxSleepTimeMs, int maxRetries)
           
 
Method Summary
 boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
          Called when an operation has failed for some reason.
 int getMaxSleepTimeMs()
           
 int getN()
           
protected  int getSleepTimeMs(int retryCount, long elapsedTimeMs)
           
 
Methods inherited from class org.apache.curator.retry.ExponentialBackoffRetry
getBaseSleepTimeMs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedExponentialBackoffRetry

public BoundedExponentialBackoffRetry(int baseSleepTimeMs,
                                      int maxSleepTimeMs,
                                      int maxRetries)
Parameters:
baseSleepTimeMs - initial amount of time to wait between retries
maxSleepTimeMs - maximum amount of time to wait between retries
maxRetries - maximum number of times to retry
Method Detail

getMaxSleepTimeMs

public int getMaxSleepTimeMs()

getSleepTimeMs

protected int getSleepTimeMs(int retryCount,
                             long elapsedTimeMs)
Overrides:
getSleepTimeMs in class ExponentialBackoffRetry

getN

public int getN()

allowRetry

public boolean allowRetry(int retryCount,
                          long elapsedTimeMs,
                          RetrySleeper sleeper)
Description copied from interface: RetryPolicy
Called when an operation has failed for some reason. This method should return true to make another attempt.

Specified by:
allowRetry in interface RetryPolicy
Parameters:
retryCount - the number of times retried so far (0 the first time)
elapsedTimeMs - the elapsed time in ms since the operation was attempted
sleeper - use this to sleep - DO NOT call Thread.sleep
Returns:
true/false


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.