FileMonitoringTimerTask (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.security.ssl, class: FileMonitoringTimerTask

Package org.apache.hadoop.security.ssl

# Class FileMonitoringTimerTask

java.lang.Object
java.util.TimerTask
org.apache.hadoop.security.ssl.FileMonitoringTimerTask

All Implemented Interfaces:
  `Runnable`

@Private public class FileMonitoringTimerTask extends TimerTask
Implements basic logic to track when a file changes on disk and call the action passed to the constructor when it does. An exception handler can optionally also be specified in the constructor, otherwise any exception occurring during process will be logged using this class' logger.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FileMonitoringTimerTask(Path filePath, Consumer<Path> onFileChange, Consumer<Throwable> onChangeFailure)`
  See `FileMonitoringTimerTask(List, Consumer, Consumer)`.
  `FileMonitoringTimerTask(List<Path> filePaths, Consumer<Path> onFileChange, Consumer<Throwable> onChangeFailure)`
  Create file monitoring task to be scheduled using a standard Java `Timer` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `run()`

  ### Methods inherited from class java.util.TimerTask

  `cancel, scheduledExecutionTime`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FileMonitoringTimerTask

    public FileMonitoringTimerTask(Path filePath, Consumer<Path> onFileChange, Consumer<Throwable> onChangeFailure)
    See `FileMonitoringTimerTask(List, Consumer, Consumer)`.
    Parameters:
      `filePath` - The file to monitor.
      `onFileChange` - What to do when the file changes.
      `onChangeFailure` - What to do when `onFileChange` throws an exception.

  - ### FileMonitoringTimerTask

    public FileMonitoringTimerTask(List<Path> filePaths, Consumer<Path> onFileChange, Consumer<Throwable> onChangeFailure)
    Create file monitoring task to be scheduled using a standard Java `Timer` instance.
    Parameters:
      `filePaths` - The path to the file to monitor.
      `onFileChange` - The function to call when the file has changed.
      `onChangeFailure` - The function to call when an exception is thrown during the file change processing.

- ## Method Details

  - ### run

    public void run()
    Specified by:
      `run` in interface `Runnable`
    Specified by:
      `run` in class `TimerTask`