Class 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 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 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.

        Parameters:
        handler - The class requesting to be called when a transition in disk space occurs
        name - 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.
        Throws:
        IllegalArgumentException - If the DiskSpaceMonitorHandler is already registered in this DiskSpaceMonitor.
        See Also:
        deregisterMonitoredDirectory(DiskSpaceMonitorHandler)
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • 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 interface AlertGenerator
        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 interface AlertGenerator
        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 interface ServerShutdownListener
        Parameters:
        reason - The human-readable reason for the shutdown.