Class BinFiles
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.util.bin.BinFiles
- All Implemented Interfaces:
ConfigurableComponent,Processor
Base class for file-binning processors.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BinManagerstatic final PropertyDescriptorstatic final PropertyDescriptorstatic final PropertyDescriptorstatic final PropertyDescriptorstatic final PropertyDescriptorstatic final PropertyDescriptorstatic final Relationshipstatic final Relationship -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<ValidationResult> Allows additional custom validation to be done.private BinFiles.BinningResultbinFlowFiles(ProcessContext context, ProcessSessionFactory sessionFactory) protected final Collection<ValidationResult> customValidate(ValidationContext context) protected abstract StringgetGroupId(ProcessContext context, FlowFile flowFile, ProcessSession session) Returns a group ID representing a bin.protected intgetMaxBinAgeSeconds(PropertyContext context) protected longgetMaxBytes(PropertyContext context) protected intgetMaxEntries(PropertyContext context) protected longgetMinBytes(PropertyContext context) protected intgetMinEntries(PropertyContext context) private intmigrateBins(ProcessContext context, boolean relaxFullnessConstraint, boolean newBinNeeded) final voidonScheduled(ProcessContext context) final voidonTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) protected abstract FlowFilepreprocessFlowFile(ProcessContext context, ProcessSession session, FlowFile flowFile) Allows general pre-processing of a flow file before it is offered to a bin.protected abstract BinProcessingResultprocessBin(Bin unmodifiableBin, ProcessContext context) Processes a single bin.protected intprocessBins(ProcessContext context, ProcessSessionFactory sessionFactory) final voidprotected abstract voidsetUpBinManager(BinManager binManager, ProcessContext context) Performs any additional setup of the bin manager.Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getRelationships, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, getSupportedPropertyDescriptors, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateProperties, migrateRelationships
-
Field Details
-
MIN_SIZE
-
MAX_SIZE
-
MIN_ENTRIES
-
MAX_ENTRIES
-
MAX_BIN_COUNT
-
MAX_BIN_AGE
-
REL_ORIGINAL
-
REL_FAILURE
-
binManager
-
readyBins
-
-
Constructor Details
-
BinFiles
public BinFiles()
-
-
Method Details
-
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- contextsession- sessionflowFile- 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- contextflowFile- flowFilesession- the session for accessing the FlowFile- Returns:
- The appropriate group ID
-
setUpBinManager
Performs any additional setup of the bin manager. Called during the OnScheduled phase.- Parameters:
binManager- The bin managercontext- 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 filescontext- The context- Returns:
trueif 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
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
-
processBins
-
binFlowFiles
private BinFiles.BinningResult binFlowFiles(ProcessContext context, ProcessSessionFactory sessionFactory) -
onScheduled
- Throws:
IOException
-
getMaxBinAgeSeconds
-
getMinBytes
-
getMaxBytes
-
getMinEntries
-
getMaxEntries
-
customValidate
- Overrides:
customValidatein classAbstractConfigurableComponent
-