Package org.archive.crawler.monitor
Class DiskSpaceMonitor
java.lang.Object
org.archive.crawler.monitor.DiskSpaceMonitor
- All Implemented Interfaces:
EventListener
,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
public class DiskSpaceMonitor
extends Object
implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
Monitors the available space on the paths configured. If the available space
drops below a specified threshold a crawl pause is requested.
Monitoring is done via the java.io.File.getUsableSpace()
method.
This method will sometimes fail on network attached storage, returning 0
bytes available even if that is not actually the case.
Paths that do not resolve to actual filesystem folders or files will not be
evaluated (i.e. if java.io.File.exists()
returns false
no further processing is carried out on that File).
Paths are checked available space whenever a StatSnapshotEvent
occurs.
- Author:
- Kristinn Sigurðsson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.archive.spring.ConfigPathConfigurer
protected CrawlController
protected boolean
protected long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkAvailableSpace
(File path) Probe via File.getUsableSpace to see if monitored paths have fallen below the pause threshold.org.archive.spring.ConfigPathConfigurer
boolean
long
void
onApplicationEvent
(org.springframework.context.ApplicationEvent event) Checks available space onStatSnapshotEvent
s.void
setConfigPathConfigurer
(org.archive.spring.ConfigPathConfigurer configPathConfigurer) Autowire access to ConfigPathConfigurervoid
setCrawlController
(CrawlController controller) Autowire access to CrawlControllervoid
setMonitorConfigPaths
(boolean monitorConfigPaths) If enabled, all the paths returned byConfigPathConfigurer.getAllConfigPaths()
will be monitored in addition to any paths explicitly specified viasetMonitorPaths(List)
.void
setMonitorPaths
(List<String> monitorPaths) void
setPauseThresholdMiB
(long pauseThresholdMiB) Set the minimum amount of space that must be available on all monitored paths.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Field Details
-
monitorPaths
-
pauseThresholdMiB
protected long pauseThresholdMiB -
controller
-
configPathConfigurer
protected org.archive.spring.ConfigPathConfigurer configPathConfigurer -
monitorConfigPaths
protected boolean monitorConfigPaths
-
-
Constructor Details
-
DiskSpaceMonitor
public DiskSpaceMonitor()
-
-
Method Details
-
setMonitorPaths
- Parameters:
monitorPaths
- List of filesystem paths that should be monitored for available space.
-
getMonitorPaths
-
setPauseThresholdMiB
public void setPauseThresholdMiB(long pauseThresholdMiB) Set the minimum amount of space that must be available on all monitored paths. If the amount falls below this pause threshold on any path the crawl will be paused.- Parameters:
pauseThresholdMiB
- The desired pause threshold value. Specified in megabytes (MiB).
-
getPauseThresholdMiB
public long getPauseThresholdMiB() -
setMonitorConfigPaths
public void setMonitorConfigPaths(boolean monitorConfigPaths) If enabled, all the paths returned byConfigPathConfigurer.getAllConfigPaths()
will be monitored in addition to any paths explicitly specified viasetMonitorPaths(List)
.true
by default.Note: This is not guaranteed to contain all paths that Heritrix writes to. It is the responsibility of modules that write to disk to register their activity with the
ConfigPathConfigurer
and some may not do so.- Parameters:
monitorConfigPaths
- If config paths should be monitored for usable space.
-
getMonitorConfigPaths
public boolean getMonitorConfigPaths() -
setCrawlController
Autowire access to CrawlController -
getCrawlController
-
setConfigPathConfigurer
@Autowired public void setConfigPathConfigurer(org.archive.spring.ConfigPathConfigurer configPathConfigurer) Autowire access to ConfigPathConfigurer -
getConfigPathConfigurer
public org.archive.spring.ConfigPathConfigurer getConfigPathConfigurer() -
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event) Checks available space onStatSnapshotEvent
s.- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
-
checkAvailableSpace
Probe via File.getUsableSpace to see if monitored paths have fallen below the pause threshold. If so, request a crawl pause.- Parameters:
path
- The filesystem path to check for usable space
-