Interface ResilienceStrategy<K,V>
- Type Parameters:
K- the type of the keys used to access data within the cacheV- the type of the values held within the cache
An implementation of this interface is used by a cache to decide how to recover after internal components of the cache fail. Implementations of these methods are expected to take suitable recovery steps. They can then choose between allowing the operation to terminate successfully, or throw an exception which will be propagated to the thread calling in to the cache.
Resilience in this context refers only to resilience against cache failures
and not to resilience against failures of any underlying
CacheLoaderWriter. To this end writer or loader failures will only be
reported to the strategy in the context of a coincident cache failure.
Isolated writer and loader exceptions will be thrown directly.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when aCache.clear()fails due to an underlying store failure.booleancontainsKeyFailure(K key, StoreAccessException e) Called when aCache.containsKey(java.lang.Object)fails due to an underlying store failure, and the resultant cache load operation also fails.getAllFailure(Iterable<? extends K> keys, StoreAccessException e) Called when aCache.getAll(java.util.Set)fails on a cache without a cache loader due to an underlying store failure.getFailure(K key, StoreAccessException e) Called when aCache.get(java.lang.Object)fails on a cache without a cache loader due to an underlying store failure.Called when a cache iterator advancement fails due to an underlying store failure.voidputAllFailure(Map<? extends K, ? extends V> entries, StoreAccessException e) Called when aCache.putAll(java.util.Map)fails due to an underlying store failure.voidputFailure(K key, V value, StoreAccessException e) Called when aCache.put(java.lang.Object, java.lang.Object)fails due to an underlying store failure.putIfAbsentFailure(K key, V value, StoreAccessException e) Called when aCache.putIfAbsent(java.lang.Object, java.lang.Object)fails due to an underlying store failure.voidremoveAllFailure(Iterable<? extends K> keys, StoreAccessException e) Called when aCache.removeAll(java.util.Set)fails due to an underlying store failure.voidremoveFailure(K key, StoreAccessException e) Called when aCache.remove(java.lang.Object)fails due to an underlying store failure.booleanremoveFailure(K key, V value, StoreAccessException e) Called when aCache.remove(Object, Object)fails due to an underlying store failure.replaceFailure(K key, V value, StoreAccessException e) Called when aCache.replace(java.lang.Object, java.lang.Object)fails due to an underlying store failure.booleanreplaceFailure(K key, V value, V newValue, StoreAccessException e) Called when aCache.replace(java.lang.Object, java.lang.Object, java.lang.Object)fails due to an underlying store failure.
-
Method Details
-
getFailure
Called when aCache.get(java.lang.Object)fails on a cache without a cache loader due to an underlying store failure.- Parameters:
key- the key being retrievede- the triggered failure- Returns:
- the value to return from the operation
-
containsKeyFailure
Called when aCache.containsKey(java.lang.Object)fails due to an underlying store failure, and the resultant cache load operation also fails.- Parameters:
key- the key being queriede- the triggered failure- Returns:
- the value to return from the operation
-
putFailure
Called when aCache.put(java.lang.Object, java.lang.Object)fails due to an underlying store failure.- Parameters:
key- the key being putvalue- the value being pute- the triggered failure
-
removeFailure
Called when aCache.remove(java.lang.Object)fails due to an underlying store failure.- Parameters:
key- the key being removede- the triggered failure
-
clearFailure
Called when aCache.clear()fails due to an underlying store failure.- Parameters:
e- the triggered failure
-
iteratorFailure
Called when a cache iterator advancement fails due to an underlying store failure.- Parameters:
e- the triggered failure- Returns:
- an entry to return on a failed iteration
-
putIfAbsentFailure
Called when aCache.putIfAbsent(java.lang.Object, java.lang.Object)fails due to an underlying store failure.If it is known at the time of calling that the key is absent from the cache (and the writer if one is present) then
knownToBeAbsentwill betrue.- Parameters:
key- the key being putvalue- the value being pute- the triggered failure- Returns:
- the value to return from the operation
-
removeFailure
Called when aCache.remove(Object, Object)fails due to an underlying store failure.- Parameters:
key- the key being removedvalue- the value being removede- the triggered failure- Returns:
- the value to return from the operation
-
replaceFailure
Called when aCache.replace(java.lang.Object, java.lang.Object)fails due to an underlying store failure.- Parameters:
key- the key being replacedvalue- the value being replacede- the triggered failure- Returns:
- the value to return from the operation
-
replaceFailure
Called when aCache.replace(java.lang.Object, java.lang.Object, java.lang.Object)fails due to an underlying store failure.- Parameters:
key- the key being replacedvalue- the expected valuenewValue- the replacement valuee- the triggered failure- Returns:
- the value to return from the operation
-
getAllFailure
Called when aCache.getAll(java.util.Set)fails on a cache without a cache loader due to an underlying store failure.- Parameters:
keys- the keys being retrievede- the triggered failure- Returns:
- the value to return from the operation
-
putAllFailure
Called when aCache.putAll(java.util.Map)fails due to an underlying store failure.- Parameters:
entries- the entries being pute- the triggered failure
-
removeAllFailure
Called when aCache.removeAll(java.util.Set)fails due to an underlying store failure.- Parameters:
keys- the keys being removede- the triggered failure
-