Class BinFiles

All Implemented Interfaces:
ConfigurableComponent, Processor

public abstract class BinFiles extends AbstractSessionFactoryProcessor
Base class for file-binning processors.
  • Field Details

  • Constructor Details

    • BinFiles

      public BinFiles()
  • Method Details

    • resetState

      @OnStopped public final void resetState()
    • preprocessFlowFile

      protected abstract FlowFile preprocessFlowFile(ProcessContext context, ProcessSession session, FlowFile flowFile)
      Allows general pre-processing of a flow file before it is offered to a bin. This is called before getGroupId().
      Parameters:
      context - context
      session - session
      flowFile - flowFile
      Returns:
      The flow file, possibly altered
    • getGroupId

      protected abstract String getGroupId(ProcessContext context, FlowFile flowFile, ProcessSession session)
      Returns a group ID representing a bin. This allows flow files to be binned into like groups.
      Parameters:
      context - context
      flowFile - flowFile
      session - the session for accessing the FlowFile
      Returns:
      The appropriate group ID
    • setUpBinManager

      protected abstract void setUpBinManager(BinManager binManager, ProcessContext context)
      Performs any additional setup of the bin manager. Called during the OnScheduled phase.
      Parameters:
      binManager - The bin manager
      context - context
    • processBin

      protected abstract BinProcessingResult processBin(Bin unmodifiableBin, ProcessContext context) throws ProcessException
      Processes a single bin. Implementing class is responsible for committing each session
      Parameters:
      unmodifiableBin - A reference to a single bin of flow files
      context - The context
      Returns:
      true if the input bin was already committed. E.g., in case of a failure, the implementation may choose to transfer all binned files to Failure and commit their sessions. If false, the processBins() method will transfer the files to Original and commit the sessions
      Throws:
      ProcessException - if any problem arises while processing a bin of FlowFiles. All flow files in the bin will be transferred to failure and the ProcessSession provided by the 'session' argument rolled back
    • additionalCustomValidation

      protected Collection<ValidationResult> additionalCustomValidation(ValidationContext context)
      Allows additional custom validation to be done. This will be called from the parent's customValidation method.
      Parameters:
      context - The context
      Returns:
      Validation results indicating problems
    • onTrigger

      public final void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
      Throws:
      ProcessException
    • migrateBins

      private int migrateBins(ProcessContext context, boolean relaxFullnessConstraint, boolean newBinNeeded)
    • getReadyBins

      protected Queue<Bin> getReadyBins()
    • processBins

      protected int processBins(ProcessContext context, ProcessSessionFactory sessionFactory)
    • binFlowFiles

      private BinFiles.BinningResult binFlowFiles(ProcessContext context, ProcessSessionFactory sessionFactory)
    • onScheduled

      @OnScheduled public final void onScheduled(ProcessContext context) throws IOException
      Throws:
      IOException
    • getMaxBinAgeSeconds

      protected int getMaxBinAgeSeconds(PropertyContext context)
    • getMinBytes

      protected long getMinBytes(PropertyContext context)
    • getMaxBytes

      protected long getMaxBytes(PropertyContext context)
    • getMinEntries

      protected int getMinEntries(PropertyContext context)
    • getMaxEntries

      protected int getMaxEntries(PropertyContext context)
    • customValidate

      protected final Collection<ValidationResult> customValidate(ValidationContext context)
      Overrides:
      customValidate in class AbstractConfigurableComponent