Class FreeSpaceMonitor


  • public class FreeSpaceMonitor
    extends java.lang.Object
    Provides a way to monitor file system locations and act when available disk space drops below a specified threshold.
    • Constructor Detail

      • FreeSpaceMonitor

        public FreeSpaceMonitor()
    • Method Detail

      • addMonitoredLocation

        public void addMonitoredLocation​(java.lang.String pathString,
                                         double freeSpaceThresholdGb)
        Adds a location to be monitored
        Parameters:
        pathString - Path string to the location to be monitored
        freeSpaceThresholdGb - Free space threshold to begin reacting to
      • whenFreeSpaceBelowThreshold

        public void whenFreeSpaceBelowThreshold​(FreeSpaceMonitorEventCallback callback)
        Allows you to register a callback which will be invoked when a monitored location is found to dip below the free space threshold.
        Parameters:
        callback - The callback to be invoked
      • whenFreeSpaceIssueResolved

        public void whenFreeSpaceIssueResolved​(FreeSpaceMonitorEventCallback callback)
        Allows you to register a callback which will be invoked when a monitored location which previously was below a free space threshold is no longer below that threshold.
        Parameters:
        callback - The callback to be invoked
      • whenErrorOccurs

        public void whenErrorOccurs​(FreeSpaceMonitorEventCallback callback)
        Allows you to register a call which will be invoked when a monitoring error occurs.
        Parameters:
        callback - The callback to be invoked
      • beginMonitoring

        public void beginMonitoring()
        Begins monitoring locations by polling them at intervals. Should later be followed by a call to shutdownMonitoring() once monitoring is no longer needed.
      • shutdownMonitoring

        public void shutdownMonitoring()
        Signals to polling thread that it should wind down and stop polling the monitored locations. See method beginMonitoring() for how to begin monitoring.