Java Code Examples for org.apache.nifi.processor.ProcessSession#migrate()
The following examples show how to use
org.apache.nifi.processor.ProcessSession#migrate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bin.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * If this bin has enough room for the size of the given flow file then it is added otherwise it is not * * @param flowFile flowfile to offer * @param session the ProcessSession to which the FlowFile belongs * @return true if added; false otherwise */ public boolean offer(final FlowFile flowFile, final ProcessSession session) { if (((size + flowFile.getSize()) > maximumSizeBytes) || (binContents.size() >= maximumEntries)) { successiveFailedOfferings++; return false; } if (fileCountAttribute != null) { final String countValue = flowFile.getAttribute(fileCountAttribute); final Integer count = toInteger(countValue); if (count != null) { int currentMaxEntries = this.maximumEntries; this.maximumEntries = Math.min(count, currentMaxEntries); this.minimumEntries = currentMaxEntries; } } size += flowFile.getSize(); session.migrate(getSession(), Collections.singleton(flowFile)); binContents.add(flowFile); successiveFailedOfferings = 0; return true; }
Example 2
Source File: Bin.java From nifi with Apache License 2.0 | 5 votes |
/** * If this bin has enough room for the size of the given flow file then it is added otherwise it is not * * @param flowFile flowfile to offer * @param session the ProcessSession to which the FlowFile belongs * @return true if added; false otherwise */ public boolean offer(final FlowFile flowFile, final ProcessSession session) { if (((size + flowFile.getSize()) > maximumSizeBytes) || (binContents.size() >= maximumEntries)) { successiveFailedOfferings++; return false; } // fileCountAttribute is non-null for defragment mode if (fileCountAttribute != null) { final String countValue = flowFile.getAttribute(fileCountAttribute); final Integer count = toInteger(countValue); if (count == null) { return false; } this.maximumEntries = count; this.minimumEntries = count; final String index = flowFile.getAttribute(FRAGMENT_INDEX_ATTRIBUTE); if (index == null || index.isEmpty() || !binIndexSet.add(index)) { // Do not accept flowfile with duplicate fragment index value logger.warn("Duplicate or missing value for '" + FRAGMENT_INDEX_ATTRIBUTE + "' in defragment mode. Flowfile {} not allowed in Bin", new Object[] { flowFile }); successiveFailedOfferings++; return false; } } size += flowFile.getSize(); session.migrate(getSession(), Collections.singleton(flowFile)); binContents.add(flowFile); successiveFailedOfferings = 0; return true; }