Class Put<FC,C extends AutoCloseable>

java.lang.Object
org.apache.nifi.processor.util.pattern.Put<FC,C>
Type Parameters:
FC - Class of context instance which is passed to each partial functions. Lifetime of an function context should be limited for a single onTrigger method.
C - Class of connection to a data storage that this pattern puts data into.
Direct Known Subclasses:
PutGroup

public class Put<FC,C extends AutoCloseable> extends Object
Abstract Put pattern class with a generic onTrigger method structure, composed with various partial functions.
  • Field Details

  • Constructor Details

    • Put

      public Put()
  • Method Details

    • putFlowFiles

      protected void putFlowFiles(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext, C connection, List<org.apache.nifi.flowfile.FlowFile> flowFiles, RoutingResult result) throws org.apache.nifi.processor.exception.ProcessException
      Put fetched FlowFiles to a data storage.
      Parameters:
      context - process context passed from a Processor onTrigger.
      session - process session passed from a Processor onTrigger.
      functionContext - function context passed from a Processor onTrigger.
      connection - connection to data storage, established by PartialFunctions.InitConnection.
      flowFiles - FlowFiles fetched from PartialFunctions.FetchFlowFiles.
      result - Route incoming FlowFiles if necessary.
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • validateCompositePattern

      protected void validateCompositePattern()
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext) throws org.apache.nifi.processor.exception.ProcessException

      Processor using this pattern is expected to call this method from its onTrigger.

      Typical usage would be constructing a process pattern instance at a processor method which is annotated with OnScheduled, and use pattern.onTrigger from processor.onTrigger.

      PartialFunctions.InitConnection is required at least. In addition to any functions required by an implementation class.

      Parameters:
      context - process context passed from a Processor onTrigger.
      session - process session passed from a Processor onTrigger.
      functionContext - function context should be instantiated per onTrigger call.
      Throws:
      org.apache.nifi.processor.exception.ProcessException - Each partial function can throw ProcessException if onTrigger should stop immediately.
    • fetchFlowFiles

      public void fetchFlowFiles(PartialFunctions.FetchFlowFiles<FC> f)
      Specify an optional function that fetches incoming FlowFIles. If not specified, single FlowFile is fetched on each onTrigger.
      Parameters:
      f - Function to fetch incoming FlowFiles.
    • initConnection

      public void initConnection(PartialFunctions.InitConnection<FC,C> f)
      Specify a function that establishes a connection to target data storage. This function will be called when there is valid incoming FlowFiles. The created connection instance is automatically closed when onTrigger is finished.
      Parameters:
      f - Function to initiate a connection to a data storage.
    • putFlowFile

      public void putFlowFile(Put.PutFlowFile<FC,C> f)
      Specify a function that puts an incoming FlowFile to target data storage.
      Parameters:
      f - a function to put a FlowFile to target storage.
    • adjustRoute

      public void adjustRoute(PartialFunctions.AdjustRoute<FC> f)
      Specify an optional function that adjust routed FlowFiles before transfer it.
      Parameters:
      f - a function to adjust route.
    • adjustFailed

      public void adjustFailed(PartialFunctions.AdjustFailed f)
      Specify an optional function that adjust if the result is failed before we call the onFailed or onCompleted function. If the result is failed, return true and do sth.
      Parameters:
      f - Function to be called to adjust if the result is failed
    • transferFlowFiles

      public void transferFlowFiles(PartialFunctions.TransferFlowFiles<FC> f)
      Specify an optional function responsible for transferring routed FlowFiles. If not specified routed FlowFiles are simply transferred to its destination by default.
      Parameters:
      f - a function to transfer routed FlowFiles.
    • onCompleted

      public void onCompleted(PartialFunctions.OnCompleted<FC,C> f)
      Specify an optional function which will be called if input FlowFiles were successfully put to a target storage.
      Parameters:
      f - Function to be called when a put operation finishes successfully.
    • onFailed

      public void onFailed(PartialFunctions.OnFailed<FC,C> f)
      Specify an optional function which will be called if input FlowFiles failed being put to a target storage.
      Parameters:
      f - Function to be called when a put operation failed.
    • cleanup

      public void cleanup(PartialFunctions.Cleanup<FC,C> f)
      Specify an optional function which will be called in a finally block. Typically useful when a special cleanup operation is needed for the connection.
      Parameters:
      f - Function to be called when a put operation finished regardless of whether it succeeded or not.
    • setLogger

      public void setLogger(org.apache.nifi.logging.ComponentLog logger)