Class DiskSpaceMonitor

  • All Implemented Interfaces:
    Runnable, AlertGenerator, ServerShutdownListener

    public class DiskSpaceMonitor
    extends MonitorProvider<MonitorProviderCfg>
    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()
        Constructs a new DiskSpaceMonitor that will notify registered DiskSpaceMonitorHandler objects when filesystems on which configured directories reside, fall below the provided thresholds.
    • Method Detail

      • startDiskSpaceMonitor

        public void startDiskSpaceMonitor()
        Starts periodic monitoring of all registered directories.
      • registerMonitoredDirectory

        public void registerMonitoredDirectory​(String instanceName,
                                               File directory,
                                               long lowThresholdBytes,
                                               long fullThresholdBytes,
                                               DiskSpaceMonitorHandler handler)
        Registers or reconfigures a directory for monitoring. If possible, we will try to get and use the mountpoint where the directory resides and monitor it instead. If the directory is already registered for the same handler, simply change its configuration.
        Parameters:
        instanceName - A name for the handler, as used by cn=monitor
        directory - The directory to monitor
        lowThresholdBytes - Disk slow threshold expressed in bytes
        fullThresholdBytes - Disk full threshold expressed in bytes
        handler - The class requesting to be called when a transition in disk space occurs
      • deregisterMonitoredDirectory

        public void deregisterMonitoredDirectory​(File directory,
                                                 DiskSpaceMonitorHandler handler)
        Removes a directory from the set of monitored directories.
        Parameters:
        directory - The directory to stop monitoring on
        handler - The class that requested monitoring
      • getMonitorInstanceName

        public String getMonitorInstanceName()
        Description copied from class: MonitorProvider
        Retrieves the name of this monitor provider. It should be unique among all monitor providers, including all instances of the same monitor provider.
        Specified by:
        getMonitorInstanceName in class MonitorProvider<MonitorProviderCfg>
        Returns:
        The name of this monitor provider.
      • getMonitorData

        public MonitorData getMonitorData()
        Description copied from class: MonitorProvider
        Retrieves a set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.
        Specified by:
        getMonitorData in class MonitorProvider<MonitorProviderCfg>
        Returns:
        A set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.
      • 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.
      • getClassName

        public String getClassName()
        Description copied from interface: AlertGenerator
        Retrieves the fully-qualified name of the Java class for this alert generator implementation.
        Specified by:
        getClassName in interface AlertGenerator
        Returns:
        The fully-qualified name of the Java class for this alert generator implementation.
      • 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​(org.forgerock.i18n.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.