Class DirectoryCleanerJob

java.lang.Object
net.solarnetwork.central.scheduler.JobSupport
net.solarnetwork.central.support.DirectoryCleanerJob
All Implemented Interfaces:
Runnable, ManagedJob, net.solarnetwork.service.PingTest

public class DirectoryCleanerJob extends JobSupport implements net.solarnetwork.service.PingTest
Job to clean out expired files from a directory.
  • Field Details

    • DEFAULT_MINIMUM_AGE

      public static final Duration DEFAULT_MINIMUM_AGE
      The minimumAge property default value.
    • DEFAULT_FREE_SPACE_WARNING_SIZE

      public static final org.springframework.util.unit.DataSize DEFAULT_FREE_SPACE_WARNING_SIZE
      The freeSpaceWarningSize property default value.
  • Constructor Details

    • DirectoryCleanerJob

      public DirectoryCleanerJob(Path directory)
      Constructor.
      Parameters:
      directory - the directory to remove files from
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getPingTestId

      public String getPingTestId()
      Specified by:
      getPingTestId in interface net.solarnetwork.service.PingTest
    • getPingTestName

      public String getPingTestName()
      Specified by:
      getPingTestName in interface net.solarnetwork.service.PingTest
    • getPingTestMaximumExecutionMilliseconds

      public long getPingTestMaximumExecutionMilliseconds()
      Specified by:
      getPingTestMaximumExecutionMilliseconds in interface net.solarnetwork.service.PingTest
    • performPingTest

      public net.solarnetwork.service.PingTest.Result performPingTest() throws Exception
      Specified by:
      performPingTest in interface net.solarnetwork.service.PingTest
      Throws:
      Exception
    • setMinutesOlder

      public void setMinutesOlder(int minutes)
      Convenience method to set the minimum age, in minutes.
      Parameters:
      minutes - the minimum age to set, in minutes
    • getMinimumAge

      public Duration getMinimumAge()
      Get the minimum age of files that can be deleted.
      Returns:
      the minimum age
    • setMinimumAge

      public void setMinimumAge(Duration minimumAge)
      Set the minimum age of files that can be deleted.
      Parameters:
      minimumAge - the age to set; if null then DEFAULT_MINIMUM_AGE will be set instead
    • getFreeSpaceWarningSize

      public org.springframework.util.unit.DataSize getFreeSpaceWarningSize()
      Get the minimum amount of free space on the file system of the configured directory before performPingTest() will fail.
      Returns:
      the free space size; defaults to DEFAULT_FREE_SPACE_WARNING_SIZE
    • setFreeSpaceWarningSize

      public void setFreeSpaceWarningSize(org.springframework.util.unit.DataSize freeSpaceWarningSize)
      Set the minimum amount of free space on the file system of the configured directory before performPingTest() will fail.
      Parameters:
      freeSpaceWarningSize - the free space size to set