Interface Processor

All Superinterfaces:
ConfigurableComponent
All Known Implementing Classes:
AbstractProcessor, AbstractSessionFactoryProcessor

public interface Processor extends ConfigurableComponent

Processor objects operate on FlowFile objects where the processors are linked together via relationships forming a directed graph structure.

The validity of a processor once established is considered safe until a configuration property of that processor is changed. Even if the property change is itself valid it still brings the validity of the processor as a whole into question. Therefore changing a processor as a whole must be reverified. Also, changing any configuration property of a processor can also imply that its supported relationships have changed.

Each Processor object is a single node in a flow graph. The same processor object on a graph may be called concurrently to update its configuration state and to perform 'onTrigger' actions. The framework also provides numerous hooks via annotations that subclasses can use to control the lifecycle of a given processor instance.

Processor objects are expected to be thread-safe and must have a public default no-args constructor to facilitate the java service loader mechanism.

  • Method Details

    • initialize

      void initialize(ProcessorInitializationContext context)
      Provides the processor with access to objects that may be of use throughout the life of the Processor
      Parameters:
      context - of initialization
    • getRelationships

      Set<Relationship> getRelationships()
      Returns:
      Set of all relationships this processor expects to transfer a flow file to. An empty set indicates this processor does not have any destination relationships. Guaranteed non null.
    • onTrigger

      void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException

      The method called when this processor is triggered to operate by the controller. In the absence of the TriggerSerially annotation, this method may be called concurrently from different threads. When this method is called depends on how this processor is configured within a controller to be triggered (timing or event based).

      Parameters:
      context - provides access to convenience methods for obtaining property values, delaying the scheduling of the processor, provides access to Controller Services, etc.
      sessionFactory - provides access to a ProcessSession, which can be used for accessing FlowFiles, etc.
      Throws:
      ProcessException - if processing did not complete normally though indicates the problem is an understood potential outcome of processing. The controller/caller will handle these exceptions gracefully such as logging, etc.. If another type of exception is allowed to propagate the controller may no longer trigger this processor to operate, as this would indicate a probable coding defect.
    • isStateful

      default boolean isStateful(ProcessContext context)
      Indicates whether this processor, configured with the given ProcessContext, stores state.
      Parameters:
      context - provides access to convenience methods for obtaining property values, delaying the scheduling of the processor, provides access to Controller Services, etc.
      Returns:
      True if this processor stores state
    • migrateProperties

      default void migrateProperties(PropertyConfiguration config)

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

      This method is called only when a Processor 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 Processor. Once called, the method will not be invoked again for this Processor until NiFi is restarted.

      Parameters:
      config - the current property configuration
    • migrateRelationships

      default void migrateRelationships(RelationshipConfiguration config)
      Allows for the migration of an old relationship configuration to a new configuration
      Parameters:
      config - the current relationship configuration