@Contract(threading=SAFE) public class DefaultFailureCache extends java.lang.Object implements FailureCache
Modifier and Type | Field and Description |
---|---|
(package private) static int |
DEFAULT_MAX_SIZE |
(package private) static int |
MAX_UPDATE_TRIES |
private int |
maxSize |
private java.util.concurrent.ConcurrentMap<java.lang.String,FailureCacheValue> |
storage |
Constructor and Description |
---|
DefaultFailureCache()
Create a new failure cache with the maximum size of
DEFAULT_MAX_SIZE . |
DefaultFailureCache(int maxSize)
Creates a new failure cache with the specified maximum size.
|
Modifier and Type | Method and Description |
---|---|
private FailureCacheValue |
findValueWithOldestTimestamp() |
int |
getErrorCount(java.lang.String identifier)
Get the current error count.
|
void |
increaseErrorCount(java.lang.String identifier)
Increases the error count by one.
|
private void |
removeOldestEntryIfMapSizeExceeded() |
void |
resetErrorCount(java.lang.String identifier)
Reset the error count back to zero.
|
private void |
updateValue(java.lang.String identifier) |
static final int DEFAULT_MAX_SIZE
static final int MAX_UPDATE_TRIES
private final int maxSize
private final java.util.concurrent.ConcurrentMap<java.lang.String,FailureCacheValue> storage
public DefaultFailureCache()
DEFAULT_MAX_SIZE
.public DefaultFailureCache(int maxSize)
maxSize
- the maximum number of entries the cache should storepublic int getErrorCount(java.lang.String identifier)
FailureCache
getErrorCount
in interface FailureCache
identifier
- the identifier for which the error count is requestedpublic void resetErrorCount(java.lang.String identifier)
FailureCache
resetErrorCount
in interface FailureCache
identifier
- the identifier for which the error count should be
resetpublic void increaseErrorCount(java.lang.String identifier)
FailureCache
increaseErrorCount
in interface FailureCache
identifier
- the identifier for which the error count should be
increasedprivate void updateValue(java.lang.String identifier)
private void removeOldestEntryIfMapSizeExceeded()
private FailureCacheValue findValueWithOldestTimestamp()