Package net.solarnetwork.central.support
Class DirectoryCleanerJob
java.lang.Object
net.solarnetwork.central.scheduler.JobSupport
net.solarnetwork.central.support.DirectoryCleanerJob
- All Implemented Interfaces:
Runnable,ManagedJob,net.solarnetwork.service.PingTest
Job to clean out expired files from a directory.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.service.PingTest
net.solarnetwork.service.PingTest.Result -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.springframework.util.unit.DataSizeThefreeSpaceWarningSizeproperty default value.static final DurationTheminimumAgeproperty default value.Fields inherited from class net.solarnetwork.central.scheduler.JobSupport
DEFAULT_CRON, DEFAULT_JITTER, DEFAULT_MAX_ITERATIONS, DEFAULT_MAX_WAIT, DEFAULT_PARALLELISM, log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.util.unit.DataSizeGet the minimum amount of free space on the file system of the configured directory beforeperformPingTest()will fail.Get the minimum age of files that can be deleted.longnet.solarnetwork.service.PingTest.Resultvoidrun()voidsetFreeSpaceWarningSize(org.springframework.util.unit.DataSize freeSpaceWarningSize) Set the minimum amount of free space on the file system of the configured directory beforeperformPingTest()will fail.voidsetMinimumAge(Duration minimumAge) Set the minimum age of files that can be deleted.voidsetMinutesOlder(int minutes) Convenience method to set the minimum age, in minutes.Methods inherited from class net.solarnetwork.central.scheduler.JobSupport
executeJobTask, executeParallelJob, getGroupId, getId, getJitter, getMaximumIterations, getMaximumWaitMs, getParallelism, getParallelTaskExecutor, getSchedule, setGroupId, setId, setJitter, setMaximumIterations, setMaximumWaitMs, setParallelism, setParallelTaskExecutor, setSchedule
-
Field Details
-
DEFAULT_MINIMUM_AGE
TheminimumAgeproperty default value. -
DEFAULT_FREE_SPACE_WARNING_SIZE
public static final org.springframework.util.unit.DataSize DEFAULT_FREE_SPACE_WARNING_SIZEThefreeSpaceWarningSizeproperty default value.
-
-
Constructor Details
-
DirectoryCleanerJob
Constructor.- Parameters:
directory- the directory to remove files from- Throws:
IllegalArgumentException- if any argument is null
-
-
Method Details
-
run
public void run() -
getPingTestId
- Specified by:
getPingTestIdin interfacenet.solarnetwork.service.PingTest
-
getPingTestName
- Specified by:
getPingTestNamein interfacenet.solarnetwork.service.PingTest
-
getPingTestMaximumExecutionMilliseconds
public long getPingTestMaximumExecutionMilliseconds()- Specified by:
getPingTestMaximumExecutionMillisecondsin interfacenet.solarnetwork.service.PingTest
-
performPingTest
- Specified by:
performPingTestin interfacenet.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
Get the minimum age of files that can be deleted.- Returns:
- the minimum age
-
setMinimumAge
Set the minimum age of files that can be deleted.- Parameters:
minimumAge- the age to set; if null thenDEFAULT_MINIMUM_AGEwill 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 beforeperformPingTest()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 beforeperformPingTest()will fail.- Parameters:
freeSpaceWarningSize- the free space size to set
-