Package org.opends.server.extensions
Class DiskSpaceMonitor
- java.lang.Object
-
- org.opends.server.api.MonitorProvider<MonitorProviderCfg>
-
- org.opends.server.extensions.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 Summary
Constructors Constructor Description DiskSpaceMonitor()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 voidderegisterMonitoredDirectory(File directory, DiskSpaceMonitorHandler handler)Removes a directory from the set of monitored directories.Map<String,String>getAlerts()Retrieves information about the set of alerts that this generator may produce.StringgetClassName()Retrieves the fully-qualified name of the Java class for this alert generator implementation.DNgetComponentEntryDN()Retrieves the DN of the configuration entry with which this alert generator is associated.MonitorDatagetMonitorData()Retrieves a set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.StringgetMonitorInstanceName()Retrieves the name of this monitor provider.StringgetShutdownListenerName()Retrieves the human-readable name for this shutdown listener.voidinitializeMonitorProvider(MonitorProviderCfg configuration)Initializes this monitor provider based on the information in the provided configuration entry.voidprocessServerShutdown(org.forgerock.i18n.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.voidregisterMonitoredDirectory(String instanceName, File directory, long lowThresholdBytes, long fullThresholdBytes, DiskSpaceMonitorHandler handler)Registers or reconfigures a directory for monitoring.voidrun()voidstartDiskSpaceMonitor()Starts periodic monitoring of all registered directories.-
Methods inherited from class org.opends.server.api.MonitorProvider
finalizeMonitorProvider, getMonitorObjectClass, isConfigurationAcceptable, scheduleUpdate
-
-
-
-
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 samehandler, simply change its configuration.- Parameters:
instanceName- A name for the handler, as used by cn=monitordirectory- The directory to monitorlowThresholdBytes- Disk slow threshold expressed in bytesfullThresholdBytes- Disk full threshold expressed in byteshandler- 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 onhandler- The class that requested monitoring
-
initializeMonitorProvider
public void initializeMonitorProvider(MonitorProviderCfg configuration) throws ConfigException, InitializationException
Description copied from class:MonitorProviderInitializes this monitor provider based on the information in the provided configuration entry.- Overrides:
initializeMonitorProviderin classMonitorProvider<MonitorProviderCfg>- Parameters:
configuration- The configuration to use to initialize this monitor provider.- Throws:
ConfigException- If an unrecoverable problem arises in the process of performing the initialization.InitializationException- If a problem occurs during initialization that is not related to the server configuration.
-
getMonitorInstanceName
public String getMonitorInstanceName()
Description copied from class:MonitorProviderRetrieves the name of this monitor provider. It should be unique among all monitor providers, including all instances of the same monitor provider.- Specified by:
getMonitorInstanceNamein classMonitorProvider<MonitorProviderCfg>- Returns:
- The name of this monitor provider.
-
getMonitorData
public MonitorData getMonitorData()
Description copied from class:MonitorProviderRetrieves a set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.- Specified by:
getMonitorDatain classMonitorProvider<MonitorProviderCfg>- Returns:
- A set of attributes containing monitor data that should be returned to the client if the corresponding monitor entry is requested.
-
getComponentEntryDN
public DN getComponentEntryDN()
Description copied from interface:AlertGeneratorRetrieves the DN of the configuration entry with which this alert generator is associated.- Specified by:
getComponentEntryDNin interfaceAlertGenerator- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getClassName
public String getClassName()
Description copied from interface:AlertGeneratorRetrieves the fully-qualified name of the Java class for this alert generator implementation.- Specified by:
getClassNamein interfaceAlertGenerator- Returns:
- The fully-qualified name of the Java class for this alert generator implementation.
-
getAlerts
public Map<String,String> getAlerts()
Description copied from interface:AlertGeneratorRetrieves 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:
getAlertsin interfaceAlertGenerator- Returns:
- Information about the set of alerts that this generator may produce.
-
getShutdownListenerName
public String getShutdownListenerName()
Description copied from interface:ServerShutdownListenerRetrieves the human-readable name for this shutdown listener.- Specified by:
getShutdownListenerNamein interfaceServerShutdownListener- Returns:
- The human-readable name for this shutdown listener.
-
processServerShutdown
public void processServerShutdown(org.forgerock.i18n.LocalizableMessage reason)
Description copied from interface:ServerShutdownListenerIndicates 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:
processServerShutdownin interfaceServerShutdownListener- Parameters:
reason- The human-readable reason for the shutdown.
-
-