Interface ReportingTask

All Superinterfaces:
ConfigurableComponent
All Known Implementing Classes:
AbstractReportingTask

public interface ReportingTask extends ConfigurableComponent
Defines a task that is responsible for reporting status information to external destinations. All implementations of this class must have a default constructor.

ReportingTasks are discovered using Java's ServiceLoader mechanism. As a result, all implementations must follow these rules:

  • The implementation must implement this interface.
  • The implementation must have a file named org.apache.nifi.reporting.ReportingTask located within the jar's META-INF/services directory. This file contains a list of fully-qualified class names of all ReportingTasks in the jar, one-per-line.
  • The implementation must support a default constructor.

ReportingTasks are scheduled on a delayed interval with a single thread. Therefore, implementations are not required to be thread-safe.

ReportingTasks may choose to annotate a method with the @OnConfigurationRestored annotation. If this is done, that method will be invoked after all properties have been set for the ReportingTask and before it is scheduled to run. If the method throws an Exception, the ReportingTask will be Administratively yielded and will not run for the configured period of time.

  • Method Details

    • initialize

      Provides the Reporting Task with access to objects that may be of use throughout the life of the service
      Parameters:
      config - of initialization context
      Throws:
      InitializationException - if unable to init
    • onTrigger

      void onTrigger(ReportingContext context)
      This method is called on a scheduled interval to allow the Reporting Task to perform its tasks.
      Parameters:
      context - reporting context
    • isStateful

      default boolean isStateful(ReportingContext context)
      Indicates whether this reporting task, configured with the given ReportingContext, stores state.
      Parameters:
      context - provides access to convenience methods for obtaining property values
      Returns:
      True if this reporting task stores state
    • migrateProperties

      default void migrateProperties(PropertyConfiguration config)

      Allows for the migration of an old property configuration to a new configuration. This allows the Reporting Task to evolve over time, as it allows properties to be renamed, removed, or reconfigured.

      This method is called only when a Reporting Task is restored from a previous configuration. For example, when NiFi is restarted and the flow is restored from disk, when a previously configured flow is imported (e.g., from a JSON file that was exported or a NiFi Registry), or when a node joins a cluster and inherits a flow that has a new Reporting Task. Once called, the method will not be invoked again for this Reporting Task until NiFi is restarted.

      Parameters:
      config - the current property configuration