Class 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 Detail

      • JadiceCacheReaper

        public JadiceCacheReaper()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • destroy

        public void destroy()
                     throws Exception
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Throws:
        Exception
      • run

        @ManagedOperation(description="Run reaping manually")
        public void run()
        Specified by:
        run in interface Runnable
      • 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 - if true 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)
        The JobScheduler on which the jadice server Jobs are executed
        Parameters:
        jobScheduler - the associated JobScheduler
      • setDocumentLayerCache

        public void setDocumentLayerCache​(ClearableDocumentLayerCache documentLayerCache)
        Replace the default DocumentLayerCache by a custom one that will be cleared whenever no jobs are running
        Parameters:
        documentLayerCache - a custom DocumentLayerCache
      • getObjectName

        public ObjectName getObjectName()
        Specified by:
        getObjectName in interface org.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()