public class DefaultTimeoutMap<K,V>
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.TimeoutMap<K,V>
TimeoutMap
.
This implementation supports thread safe and non thread safe, in the manner you can enable locking or not.
By default locking is enabled and thus we are thread safe.
You must provide a ScheduledExecutorService
in the constructor which is used
to schedule a background task which check for old entries to purge. This implementation will shutdown the scheduler
if its being stopped.
You must also invoke ServiceSupport.start()
to startup the timeout map, before its ready to be used.
And you must invoke ServiceSupport.stop()
to stop the map when no longer in use.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
Constructor and Description |
---|
DefaultTimeoutMap(ScheduledExecutorService executor) |
DefaultTimeoutMap(ScheduledExecutorService executor,
long requestMapPollTimeMillis) |
DefaultTimeoutMap(ScheduledExecutorService executor,
long requestMapPollTimeMillis,
boolean useLock) |
DefaultTimeoutMap(ScheduledExecutorService executor,
long requestMapPollTimeMillis,
Lock lock) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(org.apache.camel.TimeoutMap.Listener<K,V> listener) |
protected long |
currentTime() |
protected void |
doStart() |
protected void |
doStop() |
V |
get(K key) |
ScheduledExecutorService |
getExecutor() |
long |
getPurgePollTime() |
protected boolean |
isValidForEviction(TimeoutMapEntry<K,V> entry)
A hook to allow derivations to avoid evicting the current entry
|
protected void |
purge() |
V |
put(K key,
V value,
long timeoutMillis) |
V |
putIfAbsent(K key,
V value,
long timeoutMillis) |
V |
remove(K key) |
protected void |
schedulePoll()
lets schedule each time to allow folks to change the time at runtime
|
int |
size() |
protected void |
updateExpireTime(TimeoutMapEntry<K,V> entry) |
build, doBuild, doInit, doResume, doShutdown, doSuspend, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public DefaultTimeoutMap(ScheduledExecutorService executor)
public DefaultTimeoutMap(ScheduledExecutorService executor, long requestMapPollTimeMillis)
public DefaultTimeoutMap(ScheduledExecutorService executor, long requestMapPollTimeMillis, boolean useLock)
public DefaultTimeoutMap(ScheduledExecutorService executor, long requestMapPollTimeMillis, Lock lock)
protected void purge()
public long getPurgePollTime()
public ScheduledExecutorService getExecutor()
protected void schedulePoll()
protected boolean isValidForEviction(TimeoutMapEntry<K,V> entry)
protected void updateExpireTime(TimeoutMapEntry<K,V> entry)
protected long currentTime()
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.service.ServiceSupport
Exception
Apache Camel