Class JadiceCacheReaper
- java.lang.Object
-
- com.levigo.jadice.server.core.util.housekeeping.JadiceCacheReaper
-
- All Implemented Interfaces:
SelfRegistering
,Runnable
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.jmx.export.naming.SelfNaming
@ManagedResource("Reaper for jadice document platform objects") public class JadiceCacheReaper extends Object implements org.springframework.jmx.export.naming.SelfNaming, SelfRegistering, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, Runnable
Reaper class that attempts to clean the jadice global cache in a fixed interval to reduce memory consumption.Background: Even though jadice server uses a thread local
Cache
it might occur that some data is stored in the global cache.- Since:
- jadice server 4.4.0.2
- See Also:
CacheManager.getDefault()
-
-
Constructor Summary
Constructors Constructor Description JadiceCacheReaper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
void
destroy()
ClearableDocumentLayerCache
getDocumentLayerCache()
int
getEnqueuedCacheEntryCount()
int
getEnqueuedDocumentLayerCount()
JobScheduler
getJobScheduler()
ObjectName
getObjectName()
long
getReapedCacheEntries()
long
getReapedDocumentLayers()
int
getTimeInterval()
boolean
isReapOnlyWhenIdle()
void
run()
void
setDocumentLayerCache(ClearableDocumentLayerCache documentLayerCache)
Replace the defaultDocumentLayerCache
by a custom one that will be cleared whenever no jobs are runningvoid
setJobScheduler(JobScheduler jobScheduler)
TheJobScheduler
on which the jadice serverJob
s are executedvoid
setReapOnlyWhenIdle(boolean reapOnlyWhenIdle)
Choose if the cleansing is performed only when no jobs are running on jadice servervoid
setTimeInterval(int timeInterval)
Sets the time interval when to clean the jadice global cache
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
destroy
public void destroy() throws Exception
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
run
@ManagedOperation(description="Run reaping manually") public void run()
-
getEnqueuedDocumentLayerCount
@ManagedMetric(description="Number of enqueued non-default document layers", metricType=GAUGE) public int getEnqueuedDocumentLayerCount()
-
getEnqueuedCacheEntryCount
@ManagedMetric(description="Number of enqueued cache entries", metricType=GAUGE) public int getEnqueuedCacheEntryCount()
-
setTimeInterval
public void setTimeInterval(int timeInterval)
Sets the time interval when to clean the jadice global cache- Parameters:
timeInterval
- time interval in seconds
-
getTimeInterval
@ManagedAttribute(description="Time interval when the reaper runs (seconds)") public int getTimeInterval()
- Returns:
- The time interval when to clean the jadice global cache
-
setReapOnlyWhenIdle
public void setReapOnlyWhenIdle(boolean reapOnlyWhenIdle)
Choose if the cleansing is performed only when no jobs are running on jadice server- Parameters:
reapOnlyWhenIdle
- iftrue
the cache is only cleaned when no jobs are running
-
isReapOnlyWhenIdle
@ManagedAttribute(description="If this reaper only works when the server is idle, i.e. no jobs are running") public boolean isReapOnlyWhenIdle()
- Returns:
- if
true
the cache is only cleaned when no jobs are running
-
setJobScheduler
public void setJobScheduler(JobScheduler jobScheduler)
TheJobScheduler
on which the jadice serverJob
s are executed- Parameters:
jobScheduler
- the associatedJobScheduler
-
getJobScheduler
public JobScheduler getJobScheduler()
-
setDocumentLayerCache
public void setDocumentLayerCache(ClearableDocumentLayerCache documentLayerCache)
Replace the defaultDocumentLayerCache
by a custom one that will be cleared whenever no jobs are running- Parameters:
documentLayerCache
- a customDocumentLayerCache
-
getDocumentLayerCache
public ClearableDocumentLayerCache getDocumentLayerCache()
-
getObjectName
public ObjectName getObjectName()
- Specified by:
getObjectName
in interfaceorg.springframework.jmx.export.naming.SelfNaming
-
getReapedDocumentLayers
@ManagedMetric(metricType=COUNTER, description="Number of reaped document layers") public long getReapedDocumentLayers()
-
getReapedCacheEntries
@ManagedMetric(metricType=COUNTER, description="Number of reaped cache entries") public long getReapedCacheEntries()
-
-