public class DiskSpaceMonitor extends Object implements Runnable, AlertGenerator, ServerShutdownListener
Constructor and Description |
---|
DiskSpaceMonitor()
Constructs a new DiskSpaceMonitor that will notify registered DiskSpaceMonitorHandler objects when filesystems on
which configured directories reside, fall below the provided thresholds.
|
Modifier and Type | Method and Description |
---|---|
void |
deregisterMonitoredDirectory(DiskSpaceMonitorHandler handler)
Deregisters the provided
handler from its associated monitored disk. |
Map<String,String> |
getAlerts()
Retrieves information about the set of alerts that this generator may produce.
|
Dn |
getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert generator is associated.
|
void |
processServerShutdown(LocalizableMessage reason)
Indicates that the Directory Server has received a request to stop running and that this shutdown listener should
take any action necessary to prepare for it.
|
void |
registerMonitoredDirectory(DiskSpaceMonitorHandler handler,
String name,
File directory,
Long lowThresholdBytes,
Long fullThresholdBytes)
Registers the disk used by the provided directory to the monitored disks.
|
void |
run() |
void |
startDiskSpaceMonitor()
Starts periodic monitoring of all registered directories.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getClassName
public DiskSpaceMonitor()
public void startDiskSpaceMonitor()
public void registerMonitoredDirectory(DiskSpaceMonitorHandler handler, String name, File directory, Long lowThresholdBytes, Long fullThresholdBytes)
Disk term designates the mountpoint where the directory resides. If it is not possible to determine the mountpoint, only the directory space will be monitored.
If default thresholds have been requested, low threshold will be set at 5GB and 1GB of non reserved space if the file-system is sufficiently big. Otherwise, low and full thresholds will respectively be set at 10% and 6% of the total space available on the file-system.
A handler
is assumed to only handle a single directory, so if the provided
DiskSpaceMonitorHandler
is already registered in this DiskSpaceMonitor
, the associated directory
will no longer be monitored.
In other words, a call to deregisterMonitoredDirectory(DiskSpaceMonitorHandler)
is always performed
before registering the directory to monitor.
handler
- The class requesting to be called when a transition in disk space occursname
- Represents the name of the server element which is using the directory to monitor.
This name will only be used in server alert messages.directory
- The directory to monitor.lowThresholdBytes
- Disk low threshold expressed in bytes, or null
if the default should be used.fullThresholdBytes
- Disk full threshold expressed in bytes, or null
if the default should be used.IllegalArgumentException
- If the DiskSpaceMonitorHandler
is already registered in this DiskSpaceMonitor
.deregisterMonitoredDirectory(DiskSpaceMonitorHandler)
public void deregisterMonitoredDirectory(DiskSpaceMonitorHandler handler)
handler
from its associated monitored disk.
If the handler has not been previously registered, the method has no effect.
handler
- The DiskSpaceMonitorHandler
class that requested monitoring for a directory.registerMonitoredDirectory(DiskSpaceMonitorHandler, String, File, Long, Long)
public Dn getComponentEntryDN()
AlertGenerator
getComponentEntryDN
in interface AlertGenerator
public Map<String,String> getAlerts()
AlertGenerator
getAlerts
in interface AlertGenerator
public void processServerShutdown(LocalizableMessage reason)
ServerShutdownListener
processServerShutdown
in interface ServerShutdownListener
reason
- The human-readable reason for the shutdown.Copyright 2010-2022 ForgeRock AS.