Class DiskSpaceMonitor
- java.lang.Object
-
- org.opends.server.extensions.DiskSpaceMonitor
-
- All Implemented Interfaces:
Runnable
,AlertGenerator
,ServerShutdownListener
public class DiskSpaceMonitor extends Object implements Runnable, AlertGenerator, ServerShutdownListener
This class provides an application-wide disk space monitoring service. It provides the ability for registered handlers to receive notifications when the free disk space falls below a certain threshold. The handler will only be notified once when when the free space have dropped below any of the thresholds. Once the "full" threshold have been reached, the handler will not be notified again until the free space raises above the "low" threshold.
-
-
Constructor Summary
Constructors Constructor Description DiskSpaceMonitor(ServerContext serverContext)
Constructs a new DiskSpaceMonitor that will notify registered DiskSpaceMonitorHandler objects when filesystems on which configured directories reside, fall below the provided thresholds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deregisterMonitoredDirectory(DiskSpaceMonitorHandler handler)
Deregisters the providedhandler
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opends.server.api.AlertGenerator
getClassName
-
-
-
-
Constructor Detail
-
DiskSpaceMonitor
public DiskSpaceMonitor(ServerContext serverContext)
Constructs a new DiskSpaceMonitor that will notify registered DiskSpaceMonitorHandler objects when filesystems on which configured directories reside, fall below the provided thresholds.- Parameters:
serverContext
- The server context.
-
-
Method Detail
-
startDiskSpaceMonitor
public void startDiskSpaceMonitor()
Starts periodic monitoring of all registered directories.
-
registerMonitoredDirectory
public void registerMonitoredDirectory(DiskSpaceMonitorHandler handler, String name, File directory, Long lowThresholdBytes, Long fullThresholdBytes)
Registers the disk used by the provided directory to the monitored disks.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 providedDiskSpaceMonitorHandler
is already registered in thisDiskSpaceMonitor
, the associated directory will no longer be monitored. In other words, a call toderegisterMonitoredDirectory(DiskSpaceMonitorHandler)
is always performed before registering the directory to monitor.- Parameters:
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, ornull
if the default should be used.fullThresholdBytes
- Disk full threshold expressed in bytes, ornull
if the default should be used.- Throws:
IllegalArgumentException
- If theDiskSpaceMonitorHandler
is already registered in thisDiskSpaceMonitor
.- See Also:
deregisterMonitoredDirectory(DiskSpaceMonitorHandler)
-
deregisterMonitoredDirectory
public void deregisterMonitoredDirectory(DiskSpaceMonitorHandler handler)
Deregisters the providedhandler
from its associated monitored disk.If the handler has not been previously registered, the method has no effect.
- Parameters:
handler
- TheDiskSpaceMonitorHandler
class that requested monitoring for a directory.- See Also:
registerMonitoredDirectory(DiskSpaceMonitorHandler, String, File, Long, Long)
-
getComponentEntryDN
public Dn getComponentEntryDN()
Description copied from interface:AlertGenerator
Retrieves the DN of the configuration entry with which this alert generator is associated.- Specified by:
getComponentEntryDN
in interfaceAlertGenerator
- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getAlerts
public Map<String,String> getAlerts()
Description copied from interface:AlertGenerator
Retrieves information about the set of alerts that this generator may produce. The map returned should be between the notification type for a particular notification and the human-readable description for that notification. This alert generator must not generate any alerts with types that are not contained in this list.- Specified by:
getAlerts
in interfaceAlertGenerator
- Returns:
- Information about the set of alerts that this generator may produce.
-
processServerShutdown
public void processServerShutdown(LocalizableMessage reason)
Description copied from interface:ServerShutdownListener
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.- Specified by:
processServerShutdown
in interfaceServerShutdownListener
- Parameters:
reason
- The human-readable reason for the shutdown.
-
-