Package org.cache2k.addon
Class UniversalResiliencePolicy<K,V>
- java.lang.Object
-
- org.cache2k.addon.UniversalResiliencePolicy<K,V>
-
- All Implemented Interfaces:
org.cache2k.Customization
,org.cache2k.DataAware<K,V>
,org.cache2k.DataAwareCustomization<K,V>
,org.cache2k.expiry.ExpiryTimeValues
,org.cache2k.io.ResiliencePolicy<K,V>
public class UniversalResiliencePolicy<K,V> extends Object implements org.cache2k.io.ResiliencePolicy<K,V>
Resilience policy which implements an exponential back off of the retry intervals.- Author:
- Jens Wilke
- See Also:
- cache2k user guide - Exceptions and Resilience
-
-
Field Summary
Fields Modifier and Type Field Description static UniversalResilienceSupplier
SUPPLIER
-
Constructor Summary
Constructors Constructor Description UniversalResiliencePolicy(long resilienceDuration, long retryInterval)
Construct universal resilience policy.UniversalResiliencePolicy(long resilienceDuration, long maxRetryInterval, long retryInterval, double multiplier)
Construct universal resilience policy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
UniversalResilienceSupplier<K,V>enable(org.cache2k.Cache2kBuilder<K,V> builder)
long
getMaxRetryInterval()
double
getMultiplier()
long
getResilienceDuration()
long
getRetryInterval()
long
retryLoadAfter(K key, org.cache2k.io.LoadExceptionInfo<K,V> loadExceptionInfo)
Retries after the load time based on the retry configuration with exponential backoff.static <K,V>
UniversalResilienceSupplier<K,V>supplier()
long
suppressExceptionUntil(K key, org.cache2k.io.LoadExceptionInfo<K,V> loadExceptionInfo, org.cache2k.CacheEntry<K,V> cachedEntry)
Allows exceptions to be suppressed for a maximum of resilienceDuration starting from last successful load.
-
-
-
Field Detail
-
SUPPLIER
public static final UniversalResilienceSupplier SUPPLIER
-
-
Constructor Detail
-
UniversalResiliencePolicy
public UniversalResiliencePolicy(long resilienceDuration, long retryInterval)
Construct universal resilience policy. Duration and interval values are in milliseconds.- Parameters:
resilienceDuration
- maximum duration in which exceptions are suppressed if a previous load was successfulretryInterval
- start value of retry interval
-
UniversalResiliencePolicy
public UniversalResiliencePolicy(long resilienceDuration, long maxRetryInterval, long retryInterval, double multiplier)
Construct universal resilience policy. Duration and interval values are in milliseconds.- Parameters:
resilienceDuration
- maximum duration in which exceptions are suppressed if a previous load was successfulmaxRetryInterval
- maximum value for retryIntervalretryInterval
- start value of retry intervalmultiplier
- multiplier for retry interval in case of consecutive load exceptions
-
-
Method Detail
-
supplier
public static <K,V> UniversalResilienceSupplier<K,V> supplier()
-
enable
public static <K,V> UniversalResilienceSupplier<K,V> enable(org.cache2k.Cache2kBuilder<K,V> builder)
-
suppressExceptionUntil
public long suppressExceptionUntil(K key, org.cache2k.io.LoadExceptionInfo<K,V> loadExceptionInfo, org.cache2k.CacheEntry<K,V> cachedEntry)
Allows exceptions to be suppressed for a maximum of resilienceDuration starting from last successful load. Returns a shorter time based on the retry configuration with exponential backoff.
-
retryLoadAfter
public long retryLoadAfter(K key, org.cache2k.io.LoadExceptionInfo<K,V> loadExceptionInfo)
Retries after the load time based on the retry configuration with exponential backoff.
-
getMultiplier
public double getMultiplier()
-
getResilienceDuration
public long getResilienceDuration()
-
getMaxRetryInterval
public long getMaxRetryInterval()
-
getRetryInterval
public long getRetryInterval()
-
-