Package org.jclouds.rest.suppliers
Class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
java.lang.Object
com.google.common.collect.ForwardingObject
org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
- All Implemented Interfaces:
com.google.common.base.Supplier<T>
,Supplier<T>
public class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
extends com.google.common.collect.ForwardingObject
implements com.google.common.base.Supplier<T>
This will retry the supplier if it encounters a timeout exception, but not if it encounters an
AuthorizationException.
A shared exception reference is used so that anyone who encounters an authorizationexception will be short-circuited.
This prevents accounts from being locked out.
details
http://code.google.com/p/google-guice/issues/detail?id=483 guice doesn't remember when singleton providers throw exceptions. in this case, if the supplier fails with an authorization exception, it is called again for each provider method that depends on it. To short-circuit this, we remember the last exception trusting that guice is single-threaded. Note this implementation is folded into the same class, vs being decorated as stacktraces are exceptionally long and difficult to grok otherwise. We useLoadingCache
to deal with concurrency issues related to the supplier.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(AtomicReference<AuthorizationException> authException, com.google.common.base.Supplier<T> delegate, long duration, TimeUnit unit) create
(AtomicReference<AuthorizationException> authException, com.google.common.base.Supplier<T> delegate, long duration, TimeUnit unit, ValueLoadedCallback<T> valueLoadedCallback) Creates a memoized supplier that calls the given callback each time values are loaded.protected com.google.common.base.Supplier
<T> delegate()
get()
toString()
-
Method Details
-
create
public static <T> MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T> create(AtomicReference<AuthorizationException> authException, com.google.common.base.Supplier<T> delegate, long duration, TimeUnit unit) -
create
public static <T> MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T> create(AtomicReference<AuthorizationException> authException, com.google.common.base.Supplier<T> delegate, long duration, TimeUnit unit, ValueLoadedCallback<T> valueLoadedCallback) Creates a memoized supplier that calls the given callback each time values are loaded. -
delegate
- Specified by:
delegate
in classcom.google.common.collect.ForwardingObject
-
get
-
toString
- Overrides:
toString
in classcom.google.common.collect.ForwardingObject
-