K
- the type of the keys used to access data within the cacheV
- the type of the values held within the cachepublic interface ResilienceStrategy<K,V>
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.
Modifier and Type | Method and Description |
---|---|
void |
clearFailure(StoreAccessException e)
Called when a
Cache.clear() fails due to an underlying store
failure. |
boolean |
containsKeyFailure(K key,
StoreAccessException e)
Called when a
Cache.containsKey(java.lang.Object) fails due to an
underlying store failure, and the resultant cache load operation also fails. |
java.util.Map<K,V> |
getAllFailure(java.lang.Iterable<? extends K> keys,
StoreAccessException e)
Called when a
Cache.getAll(java.util.Set) fails on a cache
without a cache loader due to an underlying store failure. |
V |
getFailure(K key,
StoreAccessException e)
Called when a
Cache.get(java.lang.Object) fails on a cache without
a cache loader due to an underlying store failure. |
Cache.Entry<K,V> |
iteratorFailure(StoreAccessException e)
Called when a cache iterator advancement fails due to an underlying store
failure.
|
void |
putAllFailure(java.util.Map<? extends K,? extends V> entries,
StoreAccessException e)
Called when a
Cache.putAll(java.util.Map) fails due to an
underlying store failure. |
void |
putFailure(K key,
V value,
StoreAccessException e)
Called when a
Cache.put(java.lang.Object, java.lang.Object) fails
due to an underlying store failure. |
V |
putIfAbsentFailure(K key,
V value,
StoreAccessException e)
Called when a
Cache.putIfAbsent(java.lang.Object, java.lang.Object)
fails due to an underlying store failure. |
void |
removeAllFailure(java.lang.Iterable<? extends K> keys,
StoreAccessException e)
Called when a
Cache.removeAll(java.util.Set) fails due to an
underlying store failure. |
void |
removeFailure(K key,
StoreAccessException e)
Called when a
Cache.remove(java.lang.Object) fails due to an
underlying store failure. |
boolean |
removeFailure(K key,
V value,
StoreAccessException e)
Called when a
Cache.remove(Object, Object)
fails due to an underlying store failure. |
V |
replaceFailure(K key,
V value,
StoreAccessException e)
Called when a
Cache.replace(java.lang.Object, java.lang.Object)
fails due to an underlying store failure. |
boolean |
replaceFailure(K key,
V value,
V newValue,
StoreAccessException e)
Called when a
Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object)
fails due to an underlying store failure. |
V getFailure(K key, StoreAccessException e)
Cache.get(java.lang.Object)
fails on a cache without
a cache loader due to an underlying store failure.key
- the key being retrievede
- the triggered failureboolean containsKeyFailure(K key, StoreAccessException e)
Cache.containsKey(java.lang.Object)
fails due to an
underlying store failure, and the resultant cache load operation also fails.key
- the key being queriede
- the triggered failurevoid putFailure(K key, V value, StoreAccessException e)
Cache.put(java.lang.Object, java.lang.Object)
fails
due to an underlying store failure.key
- the key being putvalue
- the value being pute
- the triggered failurevoid removeFailure(K key, StoreAccessException e)
Cache.remove(java.lang.Object)
fails due to an
underlying store failure.key
- the key being removede
- the triggered failurevoid clearFailure(StoreAccessException e)
Cache.clear()
fails due to an underlying store
failure.e
- the triggered failureCache.Entry<K,V> iteratorFailure(StoreAccessException e)
e
- the triggered failureV putIfAbsentFailure(K key, V value, StoreAccessException e)
Cache.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 knownToBeAbsent
will be
true
.
key
- the key being putvalue
- the value being pute
- the triggered failureboolean removeFailure(K key, V value, StoreAccessException e)
Cache.remove(Object, Object)
fails due to an underlying store failure.key
- the key being removedvalue
- the value being removede
- the triggered failureV replaceFailure(K key, V value, StoreAccessException e)
Cache.replace(java.lang.Object, java.lang.Object)
fails due to an underlying store failure.key
- the key being replacedvalue
- the value being replacede
- the triggered failureboolean replaceFailure(K key, V value, V newValue, StoreAccessException e)
Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object)
fails due to an underlying store failure.key
- the key being replacedvalue
- the expected valuenewValue
- the replacement valuee
- the triggered failurejava.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys, StoreAccessException e)
Cache.getAll(java.util.Set)
fails on a cache
without a cache loader due to an underlying store failure.keys
- the keys being retrievede
- the triggered failurevoid putAllFailure(java.util.Map<? extends K,? extends V> entries, StoreAccessException e)
Cache.putAll(java.util.Map)
fails due to an
underlying store failure.entries
- the entries being pute
- the triggered failurevoid removeAllFailure(java.lang.Iterable<? extends K> keys, StoreAccessException e)
Cache.removeAll(java.util.Set)
fails due to an
underlying store failure.keys
- the keys being removede
- the triggered failure