@Override public int compare(final FlowFile o1, final FlowFile o2) { final int fragmentIndex1 = Integer.parseInt(o1.getAttribute(FRAGMENT_INDEX_ATTRIBUTE)); final int fragmentIndex2 = Integer.parseInt(o2.getAttribute(FRAGMENT_INDEX_ATTRIBUTE)); return Integer.compare(fragmentIndex1, fragmentIndex2); } }
private void forwardFlowFile(final ProcessContext context, final ProcessSession session, HttpRequestContainer container, final long start, final HttpServletRequest request, FlowFile flowFile) { final long receiveMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start); String subjectDn = flowFile.getAttribute(HTTPUtils.HTTP_SSL_CERT); session.getProvenanceReporter().receive(flowFile, HTTPUtils.getURI(flowFile.getAttributes()), "Received from " + request.getRemoteAddr() + (subjectDn == null ? "" : " with DN=" + subjectDn), receiveMillis); session.transfer(flowFile, REL_SUCCESS); getLogger().info("Transferring {} to 'success'; received from {}", new Object[]{flowFile, request.getRemoteAddr()}); }
private OptionalInt resolvePort(final FlowFile flowFile) { final String port; if ((port = flowFile.getAttribute("udp.port")) != null) { return OptionalInt.of(Integer.parseInt(port)); } return OptionalInt.empty(); }
@Override public ProvenanceEventBuilder fromFlowFile(final FlowFile flowFile) { setFlowFileEntryDate(flowFile.getEntryDate()); setLineageStartDate(flowFile.getLineageStartDate()); setAttributes(Collections.emptyMap(), flowFile.getAttributes()); uuid = flowFile.getAttribute(CoreAttributes.UUID.key()); this.contentSize = flowFile.getSize(); return this; }
private static SortedMap<String, String> getRelevantAttributes(final FlowFile flowFile, final Map<String, String> attributeToGeneratedNameMap) { final SortedMap<String, String> attributeMap = new TreeMap<>(); for (final Map.Entry<String, String> entry : attributeToGeneratedNameMap.entrySet()) { final String attributeName = entry.getKey(); final String attributeValue = flowFile.getAttribute(attributeName); if (attributeValue != null) { attributeMap.put(attributeName, attributeValue); } } return attributeMap; }
private void markFlowFileValid() { final List<FlowFile> groupedFlowFiles = flowFileGroups.computeIfAbsent(groupId, k -> new ArrayList<>()); final FlowFile validFlowFile; if (isBlank(flowFile.getAttribute(ATTR_STARTED_AT))) { validFlowFile = processSession.putAttribute(flowFile, ATTR_STARTED_AT, String.valueOf(now)); } else { validFlowFile = flowFile; } groupedFlowFiles.add(validFlowFile); }
/** * Returns 'true' if provided FlowFile is a failed FlowFile. A failed * FlowFile contains {@link #FAILED_PROC_ID_ATTR}. */ private boolean isFailedFlowFile(FlowFile flowFile) { return this.getIdentifier().equals(flowFile.getAttribute(FAILED_PROC_ID_ATTR)); }
@Override public Builder addParentFlowFile(final FlowFile parentFlowFile) { if (this.parentUuids == null) { this.parentUuids = new ArrayList<>(); } this.parentUuids.add(parentFlowFile.getAttribute(CoreAttributes.UUID.key())); return this; }
/** * called when the file removed */ private void onDrop(FlowFile f) { assertNotSessionFile(f); if (foe) { toDrop.remove(f.getAttribute("uuid")); } }
@Override public void assertFlowFile(FlowFile f) { Assert.assertTrue(f.getAttribute(attributeName) != null); } });
@Override public Builder removeParentFlowFile(final FlowFile parentFlowFile) { if (this.parentUuids == null) { return this; } parentUuids.remove(parentFlowFile.getAttribute(CoreAttributes.UUID.key())); return this; }
@Override public Builder removeChildFlowFile(final FlowFile childFlowFile) { if (this.childrenUuids == null) { return this; } childrenUuids.remove(childFlowFile.getAttribute(CoreAttributes.UUID.key())); return this; }
/** * called when file created or modified */ private FlowFile onMod(FlowFile f) { assertNotSessionFile(f); if (foe) { toDrop.put(f.getAttribute("uuid"), f); } return f; }
@Override public void assertFlowFile(FlowFile f) { Assert.assertTrue(f.getAttribute(attributeName) != null); } });
protected String getBasename(FlowFile flowFile, ComponentLog logger) { String basename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); if (basename.endsWith(EVTX_EXTENSION)) { return basename.substring(0, basename.length() - EVTX_EXTENSION.length()); } else { logger.warn("Trying to parse file without .evtx extension {} from flowfile {}", new Object[]{basename, flowFile}); return basename; } }
private String getPath(final FlowFile flowFile) { Path path = Paths.get(flowFile.getAttribute(CoreAttributes.PATH.key())); if (path.getNameCount() == 0) { return ""; } if (".".equals(path.getName(0).toString())) { path = path.getNameCount() == 1 ? null : path.subpath(1, path.getNameCount()); } return path == null ? "" : path.toString() + "/"; }
private void updateBuilderFromAttribute(final FlowFile flowFile, final String attribute, final Consumer<String> updater) { final String attributeValue = flowFile.getAttribute(ATTRIBUTES_PREFIX + attribute); if (attributeValue == null) { return; } try { updater.accept(attributeValue); } catch (final Exception e) { getLogger().warn("Failed to update AMQP Message Property " + attribute, e); } }
protected void processInputStream(InputStream stream, FlowFile flowFile, final Writer writer) throws IOException { int fileSize = (int) flowFile.getSize(); final InputStreamWritable inStreamWritable = new InputStreamWritable(new BufferedInputStream(stream), fileSize); String key = flowFile.getAttribute(CoreAttributes.FILENAME.key()); writer.append(new Text(key), inStreamWritable); } }
@Override protected String getGroupId(final ProcessContext context, final FlowFile flowFile, final ProcessSession session) { final String correlationAttributeName = context.getProperty(CORRELATION_ATTRIBUTE_NAME) .evaluateAttributeExpressions(flowFile).getValue(); String groupId = correlationAttributeName == null ? null : flowFile.getAttribute(correlationAttributeName); // when MERGE_STRATEGY is Defragment and correlationAttributeName is null then bin by fragment.identifier if (groupId == null && MERGE_STRATEGY_DEFRAGMENT.equals(context.getProperty(MERGE_STRATEGY).getValue())) { groupId = flowFile.getAttribute(FRAGMENT_ID_ATTRIBUTE); } return groupId; }
private OrderingContext(final ProcessContext processContext, final ProcessSession processSession) { this.processContext = processContext; this.processSession = processSession; orderAttribute = processContext.getProperty(ORDER_ATTRIBUTE).getValue(); waitTimeoutMillis = processContext.getProperty(WAIT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS); getOrder = flowFile -> Integer.parseInt(flowFile.getAttribute(orderAttribute)); groupIdentifierProperty = processContext.getProperty(GROUP_IDENTIFIER); initOrderProperty = processContext.getProperty(INITIAL_ORDER); maxOrderProperty = processContext.getProperty(MAX_ORDER); }