org.jclouds.predicates
Class RetryableNumTimesPredicate<T>

java.lang.Object
  extended by org.jclouds.predicates.RetryableNumTimesPredicate<T>
All Implemented Interfaces:
com.google.common.base.Predicate<T>

public class RetryableNumTimesPredicate<T>
extends Object
implements com.google.common.base.Predicate<T>

Retries a condition until it is met or the max number of retries have occurred. maxAttempts parameter is required. Initial retry period and retry maxPeriod are optionally configurable, defaulting to 50ms and 1000ms respectively, with the retrier increasing the interval by a factor of 1.5 each time within these constraints.

Author:
Aled Sage

Field Summary
protected  Logger logger
           
 
Constructor Summary
RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate, int maxAttempts)
           
RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate, int maxAttempts, long period, long maxPeriod, TimeUnit unit)
           
RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate, int maxAttempts, long period, TimeUnit unit)
           
 
Method Summary
 boolean apply(T input)
           
protected  long nextMaxInterval(long attempt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.common.base.Predicate
equals
 

Field Detail

logger

protected Logger logger
Constructor Detail

RetryableNumTimesPredicate

public RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate,
                                  int maxAttempts,
                                  long period,
                                  long maxPeriod,
                                  TimeUnit unit)

RetryableNumTimesPredicate

public RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate,
                                  int maxAttempts,
                                  long period,
                                  TimeUnit unit)

RetryableNumTimesPredicate

public RetryableNumTimesPredicate(com.google.common.base.Predicate<T> predicate,
                                  int maxAttempts)
Method Detail

apply

public boolean apply(T input)
Specified by:
apply in interface com.google.common.base.Predicate<T>

nextMaxInterval

protected long nextMaxInterval(long attempt)


Copyright © 2009-2012 jclouds. All Rights Reserved.