Class CachedContentCleaner

  • All Implemented Interfaces:
    java.lang.Runnable, FileHandler, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationEventPublisherAware

    public class CachedContentCleaner
    extends java.lang.Thread
    implements FileHandler, org.springframework.context.ApplicationEventPublisherAware
    Cleans up redundant cache files from the cached content file store. Once references to cache files are no longer in the in-memory cache, the binary content files can be removed.
    Author:
    Matt Ward
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()  
      void execute​(java.lang.String reasonMessage)  
      void executeAggressive​(java.lang.String reason, long targetReductionBytes)  
      java.io.File getCacheRoot()
      Returns the cacheRoot that this cleaner is responsible for.
      long getDurationMillis()  
      long getDurationSeconds()  
      long getNumFilesDeleted()  
      long getNumFilesMarked()  
      long getNumFilesSeen()  
      long getSizeFilesDeleted()  
      double getSizeFilesDeletedMB()  
      java.util.Date getTimeFinished()  
      java.util.Date getTimeStarted()  
      void handle​(java.io.File cachedContentFile)  
      void init()
      This method MUST be called after the cleaner has been fully constructed to notify interested parties that the cleaner exists and to start the actual cleaner thread.
      boolean isRunning()  
      void run()  
      void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher eventPublisher)  
      void setCache​(ContentCacheImpl cache)  
      void setMaxDeleteWatchCount​(java.lang.Integer maxDeleteWatchCount)
      Sets the maxDeleteWatchCount value.
      void setMinFileAgeMillis​(long minFileAgeMillis)
      Sets the minimum age of a cache file before it will be considered for deletion.
      void setUsageTracker​(UsageTracker usageTracker)  
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CachedContentCleaner

        public CachedContentCleaner()
    • Method Detail

      • init

        public void init()
        This method MUST be called after the cleaner has been fully constructed to notify interested parties that the cleaner exists and to start the actual cleaner thread.
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • execute

        public void execute()
      • executeAggressive

        public void executeAggressive​(java.lang.String reason,
                                      long targetReductionBytes)
      • execute

        public void execute​(java.lang.String reasonMessage)
      • handle

        public void handle​(java.io.File cachedContentFile)
        Specified by:
        handle in interface FileHandler
      • setMinFileAgeMillis

        public void setMinFileAgeMillis​(long minFileAgeMillis)
        Sets the minimum age of a cache file before it will be considered for deletion.
        Parameters:
        minFileAgeMillis - long
        See Also:
        oldEnoughForCleanup(File)
      • setMaxDeleteWatchCount

        public void setMaxDeleteWatchCount​(java.lang.Integer maxDeleteWatchCount)
        Sets the maxDeleteWatchCount value.
        Parameters:
        maxDeleteWatchCount - Integer
        See Also:
        markOrDelete(File, CacheFileProps)
      • setUsageTracker

        public void setUsageTracker​(UsageTracker usageTracker)
        Parameters:
        usageTracker - the usageTracker to set
      • isRunning

        public boolean isRunning()
      • getNumFilesSeen

        public long getNumFilesSeen()
      • getNumFilesDeleted

        public long getNumFilesDeleted()
      • getSizeFilesDeleted

        public long getSizeFilesDeleted()
      • getSizeFilesDeletedMB

        public double getSizeFilesDeletedMB()
      • getNumFilesMarked

        public long getNumFilesMarked()
      • getTimeStarted

        public java.util.Date getTimeStarted()
      • getTimeFinished

        public java.util.Date getTimeFinished()
      • getDurationSeconds

        public long getDurationSeconds()
      • getDurationMillis

        public long getDurationMillis()
      • setApplicationEventPublisher

        public void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher eventPublisher)
        Specified by:
        setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
      • getCacheRoot

        public java.io.File getCacheRoot()
        Returns the cacheRoot that this cleaner is responsible for.
        Returns:
        File