C
- component typepublic abstract class AbstractComponentTracker<C> extends Object implements ComponentTracker<C>
buildComponent(String)
, processPriorToRemoval(Object)
, and isComponentStale(Object)
methods as appropriate for their component type.Modifier and Type | Field and Description |
---|---|
static long |
LINGERING_TIMEOUT |
protected int |
maxComponents |
protected long |
timeout |
static long |
WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS
The minimum amount of time that has to elapse between successive removal iterations.
|
DEFAULT_MAX_COMPONENTS, DEFAULT_TIMEOUT
Constructor and Description |
---|
AbstractComponentTracker() |
Modifier and Type | Method and Description |
---|---|
Collection<C> |
allComponents()
Returns the collection of all components tracked by this instance.
|
Set<String> |
allKeys()
Set of all keys in this tracker in no particular order.
|
protected abstract C |
buildComponent(String key)
Build a component based on the key.
|
void |
endOfLife(String key)
Mark component identified by 'key' as having reached its end-of-life.
|
C |
find(String key)
Find the component identified by 'key', without updating the timestamp.
|
int |
getComponentCount()
Returns the number of components tracked.
|
int |
getMaxComponents() |
C |
getOrCreate(String key,
long timestamp)
Get the component identified by 'key', updating its timestamp in the
process.
|
long |
getTimeout() |
protected abstract boolean |
isComponentStale(C c)
Components can declare themselves stale.
|
protected abstract void |
processPriorToRemoval(C component)
Stop or clean the component.
|
void |
removeStaleComponents(long now)
Clear (and detach) components which are stale.
|
void |
setMaxComponents(int maxComponents) |
void |
setTimeout(long timeout) |
public static final long LINGERING_TIMEOUT
public static final long WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS
protected int maxComponents
protected long timeout
protected abstract void processPriorToRemoval(C component)
component
- protected abstract C buildComponent(String key)
key
- protected abstract boolean isComponentStale(C c)
c
- public int getComponentCount()
ComponentTracker
getComponentCount
in interface ComponentTracker<C>
public C find(String key)
Note that this method is synchronized.
find
in interface ComponentTracker<C>
key
- public C getOrCreate(String key, long timestamp)
Note that this method is atomic, i.e. synchronized.
getOrCreate
in interface ComponentTracker<C>
key
- timestamp
- public void endOfLife(String key)
endOfLife
in interface ComponentTracker<C>
key
- public void removeStaleComponents(long now)
removeStaleComponents
in interface ComponentTracker<C>
now
- public Set<String> allKeys()
ComponentTracker
allKeys
in interface ComponentTracker<C>
public Collection<C> allComponents()
ComponentTracker
allComponents
in interface ComponentTracker<C>
public long getTimeout()
public void setTimeout(long timeout)
public int getMaxComponents()
public void setMaxComponents(int maxComponents)
Copyright © 2005–2021 QOS.ch. All rights reserved.