org.ehcache.resilience
Interface ResilienceStrategy<K,V>

Type Parameters:
K - the type of the keys used to access data within the cache
V - the type of the values held within the cache
All Known Implementing Classes:
LoggingRobustResilienceStrategy, RobustResilienceStrategy

public interface ResilienceStrategy<K,V>

A strategy for providing cache resilience in the face of failure.

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
 void clearFailure(CacheAccessException e)
          Called when a Cache.clear() fails due to an underlying store failure.
 boolean containsKeyFailure(K key, CacheAccessException 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, CacheAccessException e)
          Called when a Cache.getAll(java.util.Set) fails on a cache without a cache loader due to an underlying store failure.
 java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys, CacheAccessException e, BulkCacheLoadingException f)
          Called when a Cache.getAll(java.util.Set) fails on a cache with a cache loader due to an underlying store failure, and the associated cache write operation also failed.
 java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys, java.util.Map<K,V> loaded, CacheAccessException e)
          Called when a Cache.getAll(java.util.Set) fails on a cache with a cache loader due to an underlying store failure.
 V getFailure(K key, CacheAccessException e)
          Called when a Cache.get(java.lang.Object) fails on a cache without a cache loader due to an underlying store failure.
 V getFailure(K key, CacheAccessException e, CacheLoadingException f)
          Called when a Cache.get(java.lang.Object) fails on a cache with a cache loader due to an underlying store failure.
 V getFailure(K key, V loaded, CacheAccessException e)
          Called when a Cache.get(java.lang.Object) fails on a cache with a cache loader due to an underlying store failure.
 Cache.Entry<K,V> iteratorFailure(CacheAccessException e)
          Called when a cache iterator advancement fails due to an underlying store failure.
 void putAllFailure(java.util.Map<? extends K,? extends V> entries, CacheAccessException e)
          Called when a Cache.putAll(java.util.Map) fails due to an underlying store failure.
 void putAllFailure(java.util.Map<? extends K,? extends V> entries, CacheAccessException e, BulkCacheWritingException f)
          Called when a Cache.putAll(java.util.Map) fails due to an underlying store failure, and the associated cache write operation also failed.
 void putFailure(K key, V value, CacheAccessException e)
          Called when a Cache.put(java.lang.Object, java.lang.Object) fails due to an underlying store failure.
 void putFailure(K key, V value, CacheAccessException e, CacheWritingException f)
          Called when a Cache.put(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 V putIfAbsentFailure(K key, V value, CacheAccessException e, boolean knownToBeAbsent)
          Called when a Cache.putIfAbsent(java.lang.Object, java.lang.Object) fails due to an underlying store failure.
 V putIfAbsentFailure(K key, V value, CacheAccessException e, CacheLoadingException f)
          Called when a Cache.putIfAbsent(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.
 V putIfAbsentFailure(K key, V value, CacheAccessException e, CacheWritingException f)
          Called when a Cache.putIfAbsent(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> keys, CacheAccessException e)
          Called when a Cache.removeAll(java.util.Set) fails due to an underlying store failure.
 java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> keys, CacheAccessException e, BulkCacheWritingException f)
          Called when a Cache.removeAll(java.util.Set) fails due to an underlying store failure, and the associated cache write operation also failed.
 void removeFailure(K key, CacheAccessException e)
          Called when a Cache.remove(java.lang.Object) fails due to an underlying store failure.
 void removeFailure(K key, CacheAccessException e, CacheWritingException f)
          Called when a Cache.remove(java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 boolean removeFailure(K key, V value, CacheAccessException e, boolean knownToBePresent)
          Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure.
 boolean removeFailure(K key, V value, CacheAccessException e, CacheLoadingException f)
          Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.
 boolean removeFailure(K key, V value, CacheAccessException e, CacheWritingException f)
          Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 V replaceFailure(K key, V value, CacheAccessException e)
          Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure.
 V replaceFailure(K key, V value, CacheAccessException e, CacheLoadingException f)
          Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.
 V replaceFailure(K key, V value, CacheAccessException e, CacheWritingException f)
          Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 boolean replaceFailure(K key, V value, V newValue, CacheAccessException e, boolean knownToMatch)
          Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure.
 boolean replaceFailure(K key, V value, V newValue, CacheAccessException e, CacheLoadingException f)
          Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.
 boolean replaceFailure(K key, V value, V newValue, CacheAccessException e, CacheWritingException f)
          Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.
 

Method Detail

getFailure

V getFailure(K key,
             CacheAccessException e)
Called when a Cache.get(java.lang.Object) fails on a cache without a cache loader due to an underlying store failure.

Parameters:
key - the key being retrieved
e - the triggered failure
Returns:
the value to return from the operation

getFailure

V getFailure(K key,
             V loaded,
             CacheAccessException e)
Called when a Cache.get(java.lang.Object) fails on a cache with a cache loader due to an underlying store failure.

Parameters:
key - the key being retrieved
loaded - the value from the loader
e - the triggered failure
Returns:
the value to return from the operation

getFailure

V getFailure(K key,
             CacheAccessException e,
             CacheLoadingException f)
Called when a Cache.get(java.lang.Object) fails on a cache with a cache loader due to an underlying store failure.

Parameters:
key - the key being retrieved
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

containsKeyFailure

boolean containsKeyFailure(K key,
                           CacheAccessException e)
Called when a Cache.containsKey(java.lang.Object) fails due to an underlying store failure, and the resultant cache load operation also fails.

Parameters:
key - the key being queried
e - the triggered failure
Returns:
the value to return from the operation

putFailure

void putFailure(K key,
                V value,
                CacheAccessException e)
Called when a Cache.put(java.lang.Object, java.lang.Object) fails due to an underlying store failure.

Parameters:
key - the key being put
value - the value being put
e - the triggered failure

putFailure

void putFailure(K key,
                V value,
                CacheAccessException e,
                CacheWritingException f)
Called when a Cache.put(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being put
value - the value being put
e - the cache failure
f - the writer failure

removeFailure

void removeFailure(K key,
                   CacheAccessException e)
Called when a Cache.remove(java.lang.Object) fails due to an underlying store failure.

Parameters:
key - the key being removed
e - the triggered failure

removeFailure

void removeFailure(K key,
                   CacheAccessException e,
                   CacheWritingException f)
Called when a Cache.remove(java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being removed
e - the cache failure
f - the writer failure

clearFailure

void clearFailure(CacheAccessException e)
Called when a Cache.clear() fails due to an underlying store failure.

Parameters:
e - the triggered failure

iteratorFailure

Cache.Entry<K,V> iteratorFailure(CacheAccessException e)
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

V putIfAbsentFailure(K key,
                     V value,
                     CacheAccessException e,
                     boolean knownToBeAbsent)
Called when a 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.

Parameters:
key - the key being put
value - the value being put
e - the triggered failure
knownToBeAbsent - true if the value is known to be absent
Returns:
the value to return from the operation

putIfAbsentFailure

V putIfAbsentFailure(K key,
                     V value,
                     CacheAccessException e,
                     CacheWritingException f)
Called when a Cache.putIfAbsent(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being put
value - the value being put
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

putIfAbsentFailure

V putIfAbsentFailure(K key,
                     V value,
                     CacheAccessException e,
                     CacheLoadingException f)
Called when a Cache.putIfAbsent(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.

Parameters:
key - the key being put
value - the value being put
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

removeFailure

boolean removeFailure(K key,
                      V value,
                      CacheAccessException e,
                      boolean knownToBePresent)
Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure.

If it is known at the time of calling that the targeted mapping is present in the cache (or the writer if one is present) then knownToBePresent will be true.

Parameters:
key - the key being removed
value - the value being removed
e - the triggered failure
knownToBePresent - true if the value is known to be present
Returns:
the value to return from the operation

removeFailure

boolean removeFailure(K key,
                      V value,
                      CacheAccessException e,
                      CacheWritingException f)
Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being removed
value - the value being removed
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

removeFailure

boolean removeFailure(K key,
                      V value,
                      CacheAccessException e,
                      CacheLoadingException f)
Called when a Cache.remove(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.

Parameters:
key - the key being removed
value - the value being removed
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

replaceFailure

V replaceFailure(K key,
                 V value,
                 CacheAccessException e)
Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure.

Parameters:
key - the key being replaced
value - the value being replaced
e - the triggered failure
Returns:
the value to return from the operation

replaceFailure

V replaceFailure(K key,
                 V value,
                 CacheAccessException e,
                 CacheWritingException f)
Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being replaced
value - the value being replaced
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

replaceFailure

V replaceFailure(K key,
                 V value,
                 CacheAccessException e,
                 CacheLoadingException f)
Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.

Parameters:
key - the key being replaced
value - the value being replaced
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

replaceFailure

boolean replaceFailure(K key,
                       V value,
                       V newValue,
                       CacheAccessException e,
                       boolean knownToMatch)
Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure.

If it is known at the time of calling that the target mapping is present in the cache (or the writer if one is present) then knownToBeMatch will be true.

Parameters:
key - the key being replaced
value - the expected value
newValue - the replacement value
e - the triggered failure
knownToMatch - true if the value is known to match
Returns:
the value to return from the operation

replaceFailure

boolean replaceFailure(K key,
                       V value,
                       V newValue,
                       CacheAccessException e,
                       CacheWritingException f)
Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
key - the key being replaced
value - the expected value
newValue - the replacement value
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

replaceFailure

boolean replaceFailure(K key,
                       V value,
                       V newValue,
                       CacheAccessException e,
                       CacheLoadingException f)
Called when a Cache.replace(java.lang.Object, java.lang.Object, java.lang.Object) fails due to an underlying store failure, and the associated cache load operation also failed.

Parameters:
key - the key being replaced
value - the expected value
newValue - the replacement value
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

getAllFailure

java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys,
                                 CacheAccessException e)
Called when a Cache.getAll(java.util.Set) fails on a cache without a cache loader due to an underlying store failure.

Parameters:
keys - the keys being retrieved
e - the triggered failure
Returns:
the value to return from the operation

getAllFailure

java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys,
                                 java.util.Map<K,V> loaded,
                                 CacheAccessException e)
Called when a Cache.getAll(java.util.Set) fails on a cache with a cache loader due to an underlying store failure.

Parameters:
keys - the keys being retrieved
loaded - the values from the loader
e - the triggered failure
Returns:
the value to return from the operation

getAllFailure

java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys,
                                 CacheAccessException e,
                                 BulkCacheLoadingException f)
Called when a Cache.getAll(java.util.Set) fails on a cache with a cache loader due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
keys - the keys being retrieved
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

putAllFailure

void putAllFailure(java.util.Map<? extends K,? extends V> entries,
                   CacheAccessException e)
Called when a Cache.putAll(java.util.Map) fails due to an underlying store failure.

Parameters:
entries - the entries being put
e - the triggered failure

putAllFailure

void putAllFailure(java.util.Map<? extends K,? extends V> entries,
                   CacheAccessException e,
                   BulkCacheWritingException f)
Called when a Cache.putAll(java.util.Map) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
entries - the entries being put
e - the cache failure
f - the writer failure

removeAllFailure

java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> keys,
                                    CacheAccessException e)
Called when a Cache.removeAll(java.util.Set) fails due to an underlying store failure.

Parameters:
keys - the keys being removed
e - the triggered failure
Returns:
the value to return from the operation

removeAllFailure

java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> keys,
                                    CacheAccessException e,
                                    BulkCacheWritingException f)
Called when a Cache.removeAll(java.util.Set) fails due to an underlying store failure, and the associated cache write operation also failed.

Parameters:
keys - the keys being removed
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation