org.jclouds.cache.internal
Class BackoffExponentiallyAndRetryOnThrowableCacheLoader<K,V>

java.lang.Object
  extended by com.google.common.cache.CacheLoader<K,V>
      extended by org.jclouds.cache.ForwardingCacheLoader<K,V>
          extended by org.jclouds.cache.internal.BackoffExponentiallyAndRetryOnThrowableCacheLoader<K,V>
Type Parameters:
K - the key type of the cache loader
V - the value type of the cache loader

@Beta
public class BackoffExponentiallyAndRetryOnThrowableCacheLoader<K,V>
extends ForwardingCacheLoader<K,V>

Exponentially backs off, if we encounter an exception of the given type during any of the following methods:

Since:
1.5
Author:
Adrian Cole

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jclouds.cache.ForwardingCacheLoader
ForwardingCacheLoader.SimpleForwardingCacheLoader<K,V>
 
Nested classes/interfaces inherited from class com.google.common.cache.CacheLoader
com.google.common.cache.CacheLoader.InvalidCacheLoadException
 
Constructor Summary
BackoffExponentiallyAndRetryOnThrowableCacheLoader(Class<? extends Throwable> retryableThrowable, long periodMs, long maxPeriodMs, int maxTries, com.google.common.cache.CacheLoader<K,V> loader)
           
 
Method Summary
protected  com.google.common.cache.CacheLoader<K,V> delegate()
           
 V load(K key)
           
 Map<K,V> loadAll(Iterable<? extends K> keys)
           
 com.google.common.util.concurrent.ListenableFuture<V> reload(K key, V oldValue)
           
 
Methods inherited from class com.google.common.cache.CacheLoader
from, from
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackoffExponentiallyAndRetryOnThrowableCacheLoader

public BackoffExponentiallyAndRetryOnThrowableCacheLoader(Class<? extends Throwable> retryableThrowable,
                                                          long periodMs,
                                                          long maxPeriodMs,
                                                          int maxTries,
                                                          com.google.common.cache.CacheLoader<K,V> loader)
Parameters:
retryableThrowable - the exception which we can retry
periodMs - initial period, which exponentially increases with each try, specified in milliseconds
maxPeriodMs - maximum period duration, specified in milliseconds
maxTries - maximum amount of tries
loader - the loader we are able to retry
Method Detail

delegate

protected com.google.common.cache.CacheLoader<K,V> delegate()
Specified by:
delegate in class ForwardingCacheLoader<K,V>

load

public V load(K key)
       throws Exception
Overrides:
load in class ForwardingCacheLoader<K,V>
Throws:
Exception

reload

public com.google.common.util.concurrent.ListenableFuture<V> reload(K key,
                                                                    V oldValue)
                                                             throws Exception
Overrides:
reload in class ForwardingCacheLoader<K,V>
Throws:
Exception

loadAll

public Map<K,V> loadAll(Iterable<? extends K> keys)
                 throws Exception
Overrides:
loadAll in class ForwardingCacheLoader<K,V>
Throws:
Exception


Copyright © 2009-2013 jclouds. All Rights Reserved.