@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; }
@Override public Map<String, String> getHeaders() { synchronized (headers) { if (!headersLoaded) { headers.putAll(flowFile.getAttributes()); headers.put(ENTRY_DATE_HEADER, Long.toString(flowFile.getEntryDate())); headers.put(ID_HEADER, Long.toString(flowFile.getId())); headers.put(LAST_QUEUE_DATE_HEADER, Long.toString(flowFile.getLastQueueDate())); headers.put(LINEAGE_START_DATE_HEADER, Long.toString(flowFile.getLineageStartDate())); headers.put(SIZE_HEADER, Long.toString(flowFile.getSize())); headersLoaded = true; } } return headers; }
@Override public int compare(final FlowFile o1, final FlowFile o2) { if (o1 == null && o2 == null) { return 0; } else if (o2 == null) { return -1; } else if (o1 == null) { return 1; } final int lineageDateCompare = Long.compare(o2.getLineageStartDate(), o1.getLineageStartDate()); if (lineageDateCompare != 0) { return lineageDateCompare; } return Long.compare(o2.getLineageStartIndex(), o1.getLineageStartIndex()); }
static final Map<String, String> extractFlowFileProperties(final FlowFile flowFile) { final Map<String, String> flowFileProps = new HashMap<>(); flowFileProps.put("flowFileId", String.valueOf(flowFile.getId())); flowFileProps.put("fileSize", String.valueOf(flowFile.getSize())); flowFileProps.put("entryDate", String.valueOf(flowFile.getEntryDate())); flowFileProps.put("lineageStartDate", String.valueOf(flowFile.getLineageStartDate())); flowFileProps.put("lastQueueDate", String.valueOf(flowFile.getLastQueueDate())); flowFileProps.put("queueDateIndex", String.valueOf(flowFile.getQueueDateIndex())); return flowFileProps; }
@Override public String getAttribute(String key) { return flowFile.getAttribute(key); }
@Override public long contentLength(){ return useChunked ? -1 : requestFlowFile.getSize(); } };
final String uuid = flowFile.getAttribute(CoreAttributes.UUID.key()); final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); final long size = flowFile.getSize(); final Long lastQueuedTime = flowFile.getLastQueueDate(); final long lineageStart = flowFile.getLineageStartDate(); final boolean penalized = flowFile.isPenalized();
/** * @return an unmodifiable map of the flow file attributes */ @Override public Map<String, String> getAttributes() { return flowFile.getAttributes(); }
out.writeLong(flowFile.getEntryDate()); out.writeLong(flowFile.getLineageStartDate()); out.writeLong(flowFile.getLineageStartIndex()); final Long queueDate = flowFile.getLastQueueDate(); out.writeLong(queueDate == null ? System.currentTimeMillis() : queueDate); out.writeLong(flowFile.getQueueDateIndex()); out.writeLong(flowFile.getSize()); final Map<String, String> attributes = flowFile.getAttributes(); out.writeInt(attributes.size()); for (final Map.Entry<String, String> entry : attributes.entrySet()) {
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 public void process(final InputStream in) throws IOException { final DataPacket dataPacket = new StandardDataPacket(toSend.getAttributes(), in, toSend.getSize()); codec.encode(dataPacket, checkedOutputStream); } });
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 void registerForkEvent(final FlowFile parent, final FlowFile child) { ProvenanceEventBuilder eventBuilder = forkEventBuilders.get(parent); if (eventBuilder == null) { eventBuilder = context.getProvenanceRepository().eventBuilder(); eventBuilder.setEventType(ProvenanceEventType.FORK); eventBuilder.setFlowFileEntryDate(parent.getEntryDate()); eventBuilder.setLineageStartDate(parent.getLineageStartDate()); eventBuilder.setFlowFileUUID(parent.getAttribute(CoreAttributes.UUID.key())); eventBuilder.setComponentId(context.getConnectable().getIdentifier()); final Connectable connectable = context.getConnectable(); final String processorType = connectable.getComponentType(); eventBuilder.setComponentType(processorType); eventBuilder.addParentFlowFile(parent); updateEventContentClaims(eventBuilder, parent, getRecord(parent)); forkEventBuilders.put(parent, eventBuilder); } eventBuilder.addChildFlowFile(child); }
/** * Checks if a FlowFile is known in this session. * * @param flowFile * the FlowFile to check * @return <code>true</code> if the FlowFile is known in this session, * <code>false</code> otherwise. */ boolean isFlowFileKnown(final FlowFile flowFile) { final FlowFile curFlowFile = currentVersions.get(flowFile.getId()); if (curFlowFile == null) { return false; } final String curUuid = curFlowFile.getAttribute(CoreAttributes.UUID.key()); final String providedUuid = curFlowFile.getAttribute(CoreAttributes.UUID.key()); if (!curUuid.equals(providedUuid)) { return false; } return true; } }
for (final Map.Entry<String, String> entry : parent.getAttributes().entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); fFileBuilder.lineageStart(parent.getLineageStartDate(), parent.getLineageStartIndex()); fFileBuilder.addAttributes(newAttributes);
public MockFlowFile(final long id, final FlowFile toCopy) { this.creationTime = System.nanoTime(); this.id = id; entryDate = System.currentTimeMillis(); final Map<String, String> attributesToCopy = toCopy.getAttributes(); String filename = attributesToCopy.get(CoreAttributes.FILENAME.key()); if (filename == null) { filename = String.valueOf(System.nanoTime()) + ".mockFlowFile"; } attributes.put(CoreAttributes.FILENAME.key(), filename); String path = attributesToCopy.get(CoreAttributes.PATH.key()); if (path == null) { path = "target"; } attributes.put(CoreAttributes.PATH.key(), path); String uuid = attributesToCopy.get(CoreAttributes.UUID.key()); if (uuid == null) { uuid = UUID.randomUUID().toString(); } attributes.put(CoreAttributes.UUID.key(), uuid); attributes.putAll(toCopy.getAttributes()); final byte[] dataToCopy = ((MockFlowFile) toCopy).data; this.data = new byte[dataToCopy.length]; System.arraycopy(dataToCopy, 0, this.data, 0, dataToCopy.length); this.penalized = toCopy.isPenalized(); }
@Override public long getId() { return flowFile.getId(); }
@Override public long getLineageStartDate() { return flowFile.getLineageStartDate(); }
private Long getExpirationDate(final FlowFile flowFile, final long expirationMillis) { if (flowFile == null) { return null; } if (expirationMillis <= 0) { return null; } else { final long entryDate = flowFile.getEntryDate(); final long expirationDate = entryDate + expirationMillis; return expirationDate; } }
@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); } }