@Override public void registerEvent(final ProvenanceEventRecord event) { final StandardProvenanceEventRecord newRecord; if (event instanceof StandardProvenanceEventRecord) { newRecord = (StandardProvenanceEventRecord) event; } else { newRecord = new StandardProvenanceEventRecord.Builder().fromEvent(event).build(); } newRecord.setEventId(idGenerator.getAndIncrement()); records.add(newRecord); }
private StandardProvenanceEventRecord readRecord(final DataInputStream in, final long eventId, final long startOffset, final int recordLength) throws IOException { final InputStream limitedIn = new LimitingInputStream(in, recordLength); final Record eventRecord = recordReader.readRecord(limitedIn); if (eventRecord == null) { return null; } final StandardProvenanceEventRecord deserializedEvent = LookupTableEventRecord.getEvent(eventRecord, getFilename(), startOffset, getMaxAttributeLength(), firstEventId, systemTimeOffset, componentIds, componentTypes, queueIds, eventTypes); deserializedEvent.setEventId(eventId); return deserializedEvent; }
private StandardProvenanceEventRecord readRecord(final DataInputStream inputStream, final long eventId, final long startOffset, final int recordLength) throws IOException { try { final InputStream limitedIn = new LimitingInputStream(inputStream, recordLength); byte[] encryptedSerializedBytes = new byte[recordLength]; DataInputStream encryptedInputStream = new DataInputStream(limitedIn); encryptedInputStream.readFully(encryptedSerializedBytes); byte[] plainSerializedBytes = decrypt(encryptedSerializedBytes, Long.toString(eventId)); InputStream plainStream = new ByteArrayInputStream(plainSerializedBytes); final Record eventRecord = getRecordReader().readRecord(plainStream); if (eventRecord == null) { return null; } final StandardProvenanceEventRecord deserializedEvent = LookupTableEventRecord.getEvent(eventRecord, getFilename(), startOffset, getMaxAttributeLength(), getFirstEventId(), getSystemTimeOffset(), getComponentIds(), getComponentTypes(), getQueueIds(), getEventTypes()); deserializedEvent.setEventId(eventId); return deserializedEvent; } catch (EncryptionException e) { logger.error("Encountered an error reading the record: ", e); throw new IOException(e); } }
private StandardProvenanceEventRecord truncateAttributes(final StandardProvenanceEventRecord original) { boolean requireTruncation = false; for (final String updatedAttr : original.getUpdatedAttributes().values()) { if (updatedAttr != null && updatedAttr.length() > maxAttributeChars) { requireTruncation = true; break; } } if (!requireTruncation) { for (final String previousAttr : original.getPreviousAttributes().values()) { if (previousAttr != null && previousAttr.length() > maxAttributeChars) { requireTruncation = true; break; } } } if (!requireTruncation) { return original; } final StandardProvenanceEventRecord.Builder builder = new StandardProvenanceEventRecord.Builder().fromEvent(original); builder.setAttributes(truncateAttributes(original.getPreviousAttributes()), truncateAttributes(original.getUpdatedAttributes())); final StandardProvenanceEventRecord truncated = builder.build(); truncated.setEventId(original.getEventId()); return truncated; }
record.setEventId(eventId); return record;
record.setEventId(eventId); return record;
@Override public void registerEvent(final ProvenanceEventRecord event) { final StandardProvenanceEventRecord newRecord; if (event instanceof StandardProvenanceEventRecord) { newRecord = (StandardProvenanceEventRecord) event; } else { newRecord = new StandardProvenanceEventRecord.Builder().fromEvent(event).build(); } newRecord.setEventId(idGenerator.getAndIncrement()); records.add(newRecord); }
private StandardProvenanceEventRecord truncateAttributes(final StandardProvenanceEventRecord original) { boolean requireTruncation = false; for (final String updatedAttr : original.getUpdatedAttributes().values()) { if (updatedAttr != null && updatedAttr.length() > maxAttributeChars) { requireTruncation = true; break; } } if (!requireTruncation) { for (final String previousAttr : original.getPreviousAttributes().values()) { if (previousAttr != null && previousAttr.length() > maxAttributeChars) { requireTruncation = true; break; } } } if (!requireTruncation) { return original; } final StandardProvenanceEventRecord.Builder builder = new StandardProvenanceEventRecord.Builder().fromEvent(original); builder.setAttributes(truncateAttributes(original.getPreviousAttributes()), truncateAttributes(original.getUpdatedAttributes())); final StandardProvenanceEventRecord truncated = builder.build(); truncated.setEventId(original.getEventId()); return truncated; }