Class MergeContent
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.util.bin.BinFiles
org.apache.nifi.processors.standard.MergeContent
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@TriggerWhenEmpty
@InputRequirement(INPUT_REQUIRED)
@Tags({"merge","content","correlation","tar","zip","stream","concatenation","archive","flowfile-stream","flowfile-stream-v3"})
@CapabilityDescription("Merges a Group of FlowFiles together based on a user-defined strategy and packages them into a single FlowFile. It is recommended that the Processor be configured with only a single incoming connection, as Group of FlowFiles will not be created from FlowFiles in different connections. This processor updates the mime.type attribute as appropriate. NOTE: this processor should NOT be configured with Cron Driven for the Scheduling Strategy.")
@ReadsAttribute(attribute="fragment.identifier",description="Applicable only if the <Merge Strategy> property is set to Defragment. All FlowFiles with the same value for this attribute will be bundled together.") @ReadsAttribute(attribute="fragment.index",description="Applicable only if the <Merge Strategy> property is set to Defragment. This attribute indicates the order in which the fragments should be assembled. This attribute must be present on all FlowFiles when using the Defragment Merge Strategy and must be a unique (i.e., unique across all FlowFiles that have the same value for the \"fragment.identifier\" attribute) integer between 0 and the value of the fragment.count attribute. If two or more FlowFiles have the same value for the \"fragment.identifier\" attribute and the same value for the \"fragment.index\" attribute, the first FlowFile processed will be accepted and subsequent FlowFiles will not be accepted into the Bin.") @ReadsAttribute(attribute="fragment.count",description="Applicable only if the <Merge Strategy> property is set to Defragment. This attribute indicates how many FlowFiles should be expected in the given bundle. At least one FlowFile must have this attribute in the bundle. If multiple FlowFiles contain the \"fragment.count\" attribute in a given bundle, all must have the same value.") @ReadsAttribute(attribute="segment.original.filename",description="Applicable only if the <Merge Strategy> property is set to Defragment. This attribute must be present on all FlowFiles with the same value for the fragment.identifier attribute. All FlowFiles in the same bundle must have the same value for this attribute. The value of this attribute will be used for the filename of the completed merged FlowFile.") @ReadsAttribute(attribute="tar.permissions",description="Applicable only if the <Merge Format> property is set to TAR. The value of this attribute must be 3 characters; each character must be in the range 0 to 7 (inclusive) and indicates the file permissions that should be used for the FlowFile\'s TAR entry. If this attribute is missing or has an invalid value, the default value of 644 will be used")
@WritesAttribute(attribute="filename",description="When more than 1 file is merged, the filename comes from the segment.original.filename attribute. If that attribute does not exist in the source FlowFiles, then the filename is set to the number of nanoseconds matching system time. Then a filename extension may be applied:if Merge Format is TAR, then the filename will be appended with .tar, if Merge Format is ZIP, then the filename will be appended with .zip, if Merge Format is FlowFileStream, then the filename will be appended with .pkg") @WritesAttribute(attribute="merge.count",description="The number of FlowFiles that were merged into this bundle") @WritesAttribute(attribute="merge.bin.age",description="The age of the bin, in milliseconds, when it was merged and output. Effectively this is the greatest amount of time that any FlowFile in this bundle remained waiting in this processor before it was output") @WritesAttribute(attribute="merge.uuid",description="UUID of the merged flow file that will be added to the original flow files attributes.") @WritesAttribute(attribute="merge.reason",description="This processor allows for several thresholds to be configured for merging FlowFiles. This attribute indicates which of the Thresholds resulted in the FlowFiles being merged. For an explanation of each of the possible values and their meanings, see the Processor\'s Usage / documentation and see the \'Additional Details\' page.")
@SeeAlso({SegmentContent.class,MergeRecord.class})
@SystemResourceConsideration(resource=MEMORY,
description="While content is not stored in memory, the FlowFiles\' attributes are. The configuration of MergeContent (maximum bin size, maximum group size, maximum bin age, max number of entries) will influence how much memory is used. If merging together many small FlowFiles, a two-stage approach may be necessary in order to avoid excessive use of memory.")
@UseCase(description="Concatenate FlowFiles with textual content together in order to create fewer, larger FlowFiles.",keywords={"concatenate","bundle","aggregate","bin","merge","combine","smash"},configuration="\"Merge Strategy\" = \"Bin Packing Algorithm\"\n\"Merge Format\" = \"Binary Concatenation\"\n\"Delimiter Strategy\" = \"Text\"\n\"Demarcator\" = \"\\n\" (a newline can be inserted by pressing Shift + Enter)\n\"Minimum Number of Entries\" = \"1\"\n\"Maximum Number of Entries\" = \"500000000\"\n\"Minimum Group Size\" = the minimum amount of data to write to an output FlowFile. A reasonable value might be \"128 MB\"\n\"Maximum Group Size\" = the maximum amount of data to write to an output FlowFile. A reasonable value might be \"256 MB\"\n\"Max Bin Age\" = the maximum amount of time to wait for incoming data before timing out and transferring the FlowFile along even though it is smaller than the Max Bin Age. A reasonable value might be \"5 mins\"\n") @UseCase(description="Concatenate FlowFiles with binary content together in order to create fewer, larger FlowFiles.",notes="Not all binary data can be concatenated together. Whether or not this configuration is valid depends on the type of your data.",keywords={"concatenate","bundle","aggregate","bin","merge","combine","smash"},configuration="\"Merge Strategy\" = \"Bin Packing Algorithm\"\n\"Merge Format\" = \"Binary Concatenation\"\n\"Delimiter Strategy\" = \"Text\"\n\"Minimum Number of Entries\" = \"1\"\n\"Maximum Number of Entries\" = \"500000000\"\n\"Minimum Group Size\" = the minimum amount of data to write to an output FlowFile. A reasonable value might be \"128 MB\"\n\"Maximum Group Size\" = the maximum amount of data to write to an output FlowFile. A reasonable value might be \"256 MB\"\n\"Max Bin Age\" = the maximum amount of time to wait for incoming data before timing out and transferring the FlowFile along even though it is smaller than the Max Bin Age. A reasonable value might be \"5 mins\"\n") @UseCase(description="Reassemble a FlowFile that was previously split apart into smaller FlowFiles by a processor such as SplitText, UnpackContext, SplitRecord, etc.",keywords={"reassemble","repack","merge","recombine"},configuration="\"Merge Strategy\" = \"Defragment\"\n\"Merge Format\" = the value of Merge Format depends on the desired output format. If the file was previously zipped together and was split apart by UnpackContent,\n a Merge Format of \"ZIP\" makes sense. If it was previously a .tar file, a Merge Format of \"TAR\" makes sense. If the data is textual, \"Binary Concatenation\" can be\n used to combine the text into a single document.\n\"Delimiter Strategy\" = \"Text\"\n\"Max Bin Age\" = the maximum amount of time to wait for incoming data before timing out and transferring the fragments to \'failure\'. A reasonable value might be \"5 mins\"\n\nFor textual data, \"Demarcator\" should be set to a newline (\\n), set by pressing Shift+Enter in the UI. For binary data, \"Demarcator\" should be left blank.\n")
public class MergeContent
extends BinFiles
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classstatic enumprivate classprivate static classprivate static interfacestatic enumstatic enumstatic enumprivate classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final Patternprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final Stringstatic final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> static final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final StringFields inherited from class org.apache.nifi.processor.util.bin.BinFiles
MAX_BIN_AGE, MAX_BIN_COUNT, MAX_ENTRIES, MAX_SIZE, MIN_ENTRIES, MIN_SIZE, REL_FAILURE, REL_ORIGINAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.apache.nifi.components.PropertyDescriptoraddBinPackingDependency(org.apache.nifi.components.PropertyDescriptor original) protected Collection<org.apache.nifi.components.ValidationResult> additionalCustomValidation(org.apache.nifi.components.ValidationContext context) private StringcreateFilename(List<org.apache.nifi.flowfile.FlowFile> flowFiles) private StringgetDefragmentValidationError(List<org.apache.nifi.flowfile.FlowFile> binContents) protected StringgetGroupId(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessSession session) protected longgetMaxBytes(org.apache.nifi.context.PropertyContext context) protected intgetMaxEntries(org.apache.nifi.context.PropertyContext context) protected longgetMinBytes(org.apache.nifi.context.PropertyContext context) protected intgetMinEntries(org.apache.nifi.context.PropertyContext context) private StringgetPath(org.apache.nifi.flowfile.FlowFile flowFile) Set<org.apache.nifi.processor.Relationship> protected List<org.apache.nifi.components.PropertyDescriptor> private booleanprotected org.apache.nifi.flowfile.FlowFilepreprocessFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile) protected BinProcessingResultprocessBin(Bin bin, org.apache.nifi.processor.ProcessContext context) private byte[]readContent(String filename) private voidremoveFlowFileFromSession(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context) protected voidsetUpBinManager(BinManager binManager, org.apache.nifi.processor.ProcessContext context) Methods inherited from class org.apache.nifi.processor.util.bin.BinFiles
customValidate, getMaxBinAgeSeconds, getReadyBins, onScheduled, onTrigger, processBins, resetStateMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, 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
-
FRAGMENT_ID_ATTRIBUTE
-
FRAGMENT_INDEX_ATTRIBUTE
-
FRAGMENT_COUNT_ATTRIBUTE
-
SEGMENT_ORIGINAL_FILENAME
-
TAR_PERMISSIONS_ATTRIBUTE
- See Also:
-
MERGE_COUNT_ATTRIBUTE
- See Also:
-
MERGE_BIN_AGE_ATTRIBUTE
- See Also:
-
MERGE_UUID_ATTRIBUTE
- See Also:
-
REASON_FOR_MERGING
- See Also:
-
MERGE_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor MERGE_STRATEGY -
MERGE_FORMAT
public static final org.apache.nifi.components.PropertyDescriptor MERGE_FORMAT -
METADATA_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor METADATA_STRATEGY -
CORRELATION_ATTRIBUTE_NAME
public static final org.apache.nifi.components.PropertyDescriptor CORRELATION_ATTRIBUTE_NAME -
DELIMITER_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor DELIMITER_STRATEGY -
HEADER
public static final org.apache.nifi.components.PropertyDescriptor HEADER -
FOOTER
public static final org.apache.nifi.components.PropertyDescriptor FOOTER -
DEMARCATOR
public static final org.apache.nifi.components.PropertyDescriptor DEMARCATOR -
COMPRESSION_LEVEL
public static final org.apache.nifi.components.PropertyDescriptor COMPRESSION_LEVEL -
KEEP_PATH
public static final org.apache.nifi.components.PropertyDescriptor KEEP_PATH -
TAR_MODIFIED_TIME
public static final org.apache.nifi.components.PropertyDescriptor TAR_MODIFIED_TIME -
BIN_TERMINATION_CHECK
public static final org.apache.nifi.components.PropertyDescriptor BIN_TERMINATION_CHECK -
FLOWFILE_INSERTION_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor FLOWFILE_INSERTION_STRATEGY -
PROPERTY_DESCRIPTORS
-
REL_MERGED
public static final org.apache.nifi.processor.Relationship REL_MERGED -
RELATIONSHIPS
-
NUMBER_PATTERN
-
-
Constructor Details
-
MergeContent
public MergeContent()
-
-
Method Details
-
addBinPackingDependency
private static org.apache.nifi.components.PropertyDescriptor addBinPackingDependency(org.apache.nifi.components.PropertyDescriptor original) -
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
additionalCustomValidation
protected Collection<org.apache.nifi.components.ValidationResult> additionalCustomValidation(org.apache.nifi.components.ValidationContext context) - Overrides:
additionalCustomValidationin classBinFiles
-
readContent
- Throws:
IOException
-
preprocessFlowFile
protected org.apache.nifi.flowfile.FlowFile preprocessFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile) - Specified by:
preprocessFlowFilein classBinFiles
-
getGroupId
protected String getGroupId(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessSession session) - Specified by:
getGroupIdin classBinFiles
-
setUpBinManager
protected void setUpBinManager(BinManager binManager, org.apache.nifi.processor.ProcessContext context) - Specified by:
setUpBinManagerin classBinFiles
-
processBin
protected BinProcessingResult processBin(Bin bin, org.apache.nifi.processor.ProcessContext context) throws org.apache.nifi.processor.exception.ProcessException - Specified by:
processBinin classBinFiles- Throws:
org.apache.nifi.processor.exception.ProcessException
-
getMinEntries
protected int getMinEntries(org.apache.nifi.context.PropertyContext context) - Overrides:
getMinEntriesin classBinFiles
-
getMaxEntries
protected int getMaxEntries(org.apache.nifi.context.PropertyContext context) - Overrides:
getMaxEntriesin classBinFiles
-
getMinBytes
protected long getMinBytes(org.apache.nifi.context.PropertyContext context) - Overrides:
getMinBytesin classBinFiles
-
getMaxBytes
protected long getMaxBytes(org.apache.nifi.context.PropertyContext context) - Overrides:
getMaxBytesin classBinFiles
-
getDefragmentValidationError
-
isNumber
-
removeFlowFileFromSession
private void removeFlowFileFromSession(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, org.apache.nifi.processor.ProcessContext context) -
getPath
-
createFilename
-