org.ehcache.resilience
Class RobustResilienceStrategy<K,V>

java.lang.Object
  extended by org.ehcache.resilience.RobustResilienceStrategy<K,V>
All Implemented Interfaces:
ResilienceStrategy<K,V>
Direct Known Subclasses:
LoggingRobustResilienceStrategy

public abstract class RobustResilienceStrategy<K,V>
extends java.lang.Object
implements ResilienceStrategy<K,V>


Constructor Summary
RobustResilienceStrategy(RecoveryCache<K> cache)
           
 
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.
protected abstract  void inconsistent(CacheAccessException because, CacheAccessException... cleanup)
           
protected abstract  void inconsistent(java.lang.Iterable<? extends K> keys, CacheAccessException because, CacheAccessException... cleanup)
           
protected abstract  void inconsistent(K key, CacheAccessException because, CacheAccessException... cleanup)
           
abstract  void 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.
protected abstract  void recovered(CacheAccessException from)
           
protected abstract  void recovered(java.lang.Iterable<? extends K> keys, CacheAccessException from)
           
protected abstract  void recovered(K key, CacheAccessException from)
           
 java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> entries, 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> entries, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RobustResilienceStrategy

public RobustResilienceStrategy(RecoveryCache<K> cache)
Method Detail

getFailure

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

Specified by:
getFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being retrieved
e - the triggered failure
Returns:
the value to return from the operation

getFailure

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

Specified by:
getFailure in interface ResilienceStrategy<K,V>
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

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

Specified by:
getFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being retrieved
e - the cache failure
f - the loader failure
Returns:
the value to return from the operation

containsKeyFailure

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

Specified by:
containsKeyFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being queried
e - the triggered failure
Returns:
the value to return from the operation

putFailure

public void putFailure(K key,
                       V value,
                       CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a Cache.put(java.lang.Object, java.lang.Object) fails due to an underlying store failure.

Specified by:
putFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being put
value - the value being put
e - the triggered failure

putFailure

public void putFailure(K key,
                       V value,
                       CacheAccessException e,
                       CacheWritingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
putFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being put
value - the value being put
e - the cache failure
f - the writer failure

removeFailure

public void removeFailure(K key,
                          CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a Cache.remove(java.lang.Object) fails due to an underlying store failure.

Specified by:
removeFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being removed
e - the triggered failure

removeFailure

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

Specified by:
removeFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being removed
e - the cache failure
f - the writer failure

clearFailure

public void clearFailure(CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a Cache.clear() fails due to an underlying store failure.

Specified by:
clearFailure in interface ResilienceStrategy<K,V>
Parameters:
e - the triggered failure

iteratorFailure

public abstract void iteratorFailure(CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a cache iterator advancement fails due to an underlying store failure.

Specified by:
iteratorFailure in interface ResilienceStrategy<K,V>
Parameters:
e - the triggered failure

putIfAbsentFailure

public V putIfAbsentFailure(K key,
                            V value,
                            CacheAccessException e,
                            boolean knownToBeAbsent)
Description copied from interface: ResilienceStrategy
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.

Specified by:
putIfAbsentFailure in interface ResilienceStrategy<K,V>
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

public V putIfAbsentFailure(K key,
                            V value,
                            CacheAccessException e,
                            CacheWritingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
putIfAbsentFailure in interface ResilienceStrategy<K,V>
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

public V putIfAbsentFailure(K key,
                            V value,
                            CacheAccessException e,
                            CacheLoadingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
putIfAbsentFailure in interface ResilienceStrategy<K,V>
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

public boolean removeFailure(K key,
                             V value,
                             CacheAccessException e,
                             boolean knownToBePresent)
Description copied from interface: ResilienceStrategy
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.

Specified by:
removeFailure in interface ResilienceStrategy<K,V>
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

public boolean removeFailure(K key,
                             V value,
                             CacheAccessException e,
                             CacheWritingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
removeFailure in interface ResilienceStrategy<K,V>
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

public boolean removeFailure(K key,
                             V value,
                             CacheAccessException e,
                             CacheLoadingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
removeFailure in interface ResilienceStrategy<K,V>
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

public V replaceFailure(K key,
                        V value,
                        CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a Cache.replace(java.lang.Object, java.lang.Object) fails due to an underlying store failure.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
Parameters:
key - the key being replaced
value - the value being replaced
e - the triggered failure
Returns:
the value to return from the operation

replaceFailure

public V replaceFailure(K key,
                        V value,
                        CacheAccessException e,
                        CacheWritingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
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

public V replaceFailure(K key,
                        V value,
                        CacheAccessException e,
                        CacheLoadingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
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

public boolean replaceFailure(K key,
                              V value,
                              V newValue,
                              CacheAccessException e,
                              boolean knownToMatch)
Description copied from interface: ResilienceStrategy
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.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
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

public boolean replaceFailure(K key,
                              V value,
                              V newValue,
                              CacheAccessException e,
                              CacheWritingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
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

public boolean replaceFailure(K key,
                              V value,
                              V newValue,
                              CacheAccessException e,
                              CacheLoadingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
replaceFailure in interface ResilienceStrategy<K,V>
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

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

Specified by:
getAllFailure in interface ResilienceStrategy<K,V>
Parameters:
keys - the keys being retrieved
e - the triggered failure
Returns:
the value to return from the operation

getAllFailure

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

Specified by:
getAllFailure in interface ResilienceStrategy<K,V>
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

public java.util.Map<K,V> getAllFailure(java.lang.Iterable<? extends K> keys,
                                        CacheAccessException e,
                                        BulkCacheLoadingException f)
Description copied from interface: ResilienceStrategy
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.

Specified by:
getAllFailure in interface ResilienceStrategy<K,V>
Parameters:
keys - the keys being retrieved
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

putAllFailure

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

Specified by:
putAllFailure in interface ResilienceStrategy<K,V>
Parameters:
entries - the entries being put
e - the triggered failure

putAllFailure

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

Specified by:
putAllFailure in interface ResilienceStrategy<K,V>
Parameters:
entries - the entries being put
e - the cache failure
f - the writer failure

removeAllFailure

public java.util.Map<K,V> removeAllFailure(java.lang.Iterable<? extends K> entries,
                                           CacheAccessException e)
Description copied from interface: ResilienceStrategy
Called when a Cache.removeAll(java.util.Set) fails due to an underlying store failure.

Specified by:
removeAllFailure in interface ResilienceStrategy<K,V>
Parameters:
entries - the keys being removed
e - the triggered failure
Returns:
the value to return from the operation

removeAllFailure

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

Specified by:
removeAllFailure in interface ResilienceStrategy<K,V>
Parameters:
entries - the keys being removed
e - the cache failure
f - the writer failure
Returns:
the value to return from the operation

recovered

protected abstract void recovered(K key,
                                  CacheAccessException from)

recovered

protected abstract void recovered(java.lang.Iterable<? extends K> keys,
                                  CacheAccessException from)

recovered

protected abstract void recovered(CacheAccessException from)

inconsistent

protected abstract void inconsistent(K key,
                                     CacheAccessException because,
                                     CacheAccessException... cleanup)

inconsistent

protected abstract void inconsistent(java.lang.Iterable<? extends K> keys,
                                     CacheAccessException because,
                                     CacheAccessException... cleanup)

inconsistent

protected abstract void inconsistent(CacheAccessException because,
                                     CacheAccessException... cleanup)