public class AbsentResourceList
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbsentResourceList.AbsentResourceEntry
Internal class that maintains a resource's state.
|
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_ABSENT_RESOURCE_TRIES
The default number of times a resource is marked as absent before being marked as permanently absent.
|
protected static int |
DEFAULT_MIN_ABSENT_RESOURCE_CHECK_INTERVAL
The default interval to wait before indicating the resource is not absent.
|
protected static int |
DEFAULT_TRY_AGAIN_INTERVAL
The default interval at which a resources is marked as not absent after having been marked permanently absent.
|
protected int |
maxTries
The maximum number of times a resource is marked as absent before being marked as permanently absent.
|
protected int |
minCheckInterval
The interval to wait, in milliseconds, before indicating the resource is not absent.
|
protected BasicSessionCache |
possiblyAbsent
The map of absent resources.
|
protected int |
tryAgainInterval
The interval at which a resource is marked as not absent after having been marked as permanently absent.
|
Constructor and Description |
---|
AbsentResourceList()
Construct an absent-resource list with default values for max tries (3), check interval (10 seconds) and
try-again interval (60 seconds).
|
AbsentResourceList(java.lang.Integer cacheSize,
int maxTries,
int minCheckInterval,
int tryAgainInterval)
Construct an absent-resource list with a specified number of maximum tries, a check interval and a retry
interval.
|
AbsentResourceList(int maxTries,
int minCheckInterval)
Construct an absent-resource list with a specified number of maximum tries and a check interval.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxTries()
Indicates the maximum number of times a resource is marked as absent before being marked as permanently absent.
|
int |
getMinCheckInterval()
Indicates the time interval that must elapse before the resource is considered not absent if its max-tries has
not been reached.
|
int |
getTryAgainInterval()
Indicates the time interval that must elapse before a resource marked as permanently absent is again considered
not absent.
|
boolean |
isResourceAbsent(long resourceID)
Indicates whether a resource is considered absent.
|
boolean |
isResourceAbsent(java.lang.String resourceID)
Indicates whether a resource is considered absent.
|
void |
markResourceAbsent(long resourceID)
Mark a specified resource as absent.
|
void |
markResourceAbsent(java.lang.String resourceID)
Mark a specified resource as absent.
|
void |
setMaxTries(int maxTries)
Specifies the maximum number of times a resource is marked as absent before being marked as permanently absent.
|
void |
setMinCheckInterval(int minCheckInterval)
Specifies the time interval that must elapse before the resource is considered absent if its max-tries has not
been reached.
|
void |
setTryAgainInterval(int tryAgainInterval)
Specifies the time interval that must elapse before a resource marked as permanently absent is again considered
not absent.
|
void |
unmarkResourceAbsent(long resourceID)
Mark the resource as not-absent, effectively removing it from this absent-resource list.
|
void |
unmarkResourceAbsent(java.lang.String resourceID)
Remove a resource from this absent-resource list if the resource is contained in the list.
|
protected static final int DEFAULT_MAX_ABSENT_RESOURCE_TRIES
protected static final int DEFAULT_MIN_ABSENT_RESOURCE_CHECK_INTERVAL
protected static final int DEFAULT_TRY_AGAIN_INTERVAL
protected int maxTries
protected int minCheckInterval
protected BasicSessionCache possiblyAbsent
protected int tryAgainInterval
public AbsentResourceList()
public AbsentResourceList(java.lang.Integer cacheSize, int maxTries, int minCheckInterval, int tryAgainInterval)
cacheSize
- the maximum number of absent resources the list may hold. If this limit is exceeded, the
oldest entries in the list are ejected and the resources they refer to are subsequently
not considered to be absent resources.maxTries
- the number of max tries. Must be greater than 0.minCheckInterval
- the check interval. Must be greater than or equal to 0.tryAgainInterval
- the try-again interval. Must be greater than or equal to 0.java.lang.IllegalArgumentException
- if max-tries is less than 1 or if either the minimum check interval or try-again
interval is less than 0.public AbsentResourceList(int maxTries, int minCheckInterval)
maxTries
- the number of max tries. Must be greater than 0.minCheckInterval
- the check interval. Must be greater than or equal to 0.java.lang.IllegalArgumentException
- if max-tries is less than 1 or the minimum check interval is less than 0.public int getMaxTries()
public int getMinCheckInterval()
public int getTryAgainInterval()
public final boolean isResourceAbsent(long resourceID)
resourceID
- the resource in question.public final boolean isResourceAbsent(java.lang.String resourceID)
resourceID
- the resource in question.public final void markResourceAbsent(long resourceID)
resourceID
- the resource to mark as absent.public final void markResourceAbsent(java.lang.String resourceID)
resourceID
- the resource to mark as absent.public void setMaxTries(int maxTries)
maxTries
- the number of max tries. Must be greater than 0.java.lang.IllegalArgumentException
- if max-tries is less than 1.public void setMinCheckInterval(int minCheckInterval)
minCheckInterval
- the check interval. Must be greater than or equal to 0.java.lang.IllegalArgumentException
- if the minimum check interval is less than 0.public void setTryAgainInterval(int tryAgainInterval)
tryAgainInterval
- the try-again interval. Must be greater than or equal to 0.java.lang.IllegalArgumentException
- if the try-again interval is less than 0.public final void unmarkResourceAbsent(long resourceID)
resourceID
- the resource to mark as not absent.public final void unmarkResourceAbsent(java.lang.String resourceID)
resourceID
- the resource to remove from this list.