Skip to content

Commit

Permalink
NIFI-12855: Add more information to provenance events to facilitate f…
Browse files Browse the repository at this point in the history
…ull graph traversal

Generate event IDs earlier so previousEventIds can be updated accurately

Added flow graph components to provenance graph

Fix component nodes to update properties rather than a new node

Add capabilities (some placeholders) for creating the database and indexes, added relationship property to 'outgoing' provenance events

Added relationships to all provenance events except clone and join, also some Cypher improvements

Added some fine-grained exceptions for better error handling/reporting

Split query generation API from GraphClientService into finer-grained methods

Replace Collections.emptyList() with ArrayList<>[0] for modifiability

Fix copyright headers
  • Loading branch information
mattyb149 committed Mar 6, 2024
1 parent af63871 commit 81d7061
Show file tree
Hide file tree
Showing 238 changed files with 2,051 additions and 1,346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class NoOpProvenanceRepository implements ProvenanceRepository {

@Override
public void initialize(EventReporter eventReporter, Authorizer authorizer,
ProvenanceAuthorizableFactory factory, IdentifierLookup identifierLookup)
throws IOException {
ProvenanceAuthorizableFactory factory, IdentifierLookup identifierLookup)
throws IOException {

}

Expand All @@ -69,13 +69,13 @@ public ProvenanceEventRecord getEvent(final long id, final NiFiUser user) throws

@Override
public List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords)
throws IOException {
throws IOException {
return emptyList();
}

@Override
public List<ProvenanceEventRecord> getEvents(long firstRecordId,
int maxRecords, NiFiUser niFiUser) throws IOException {
int maxRecords, NiFiUser niFiUser) throws IOException {
return emptyList();
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public long getContainerUsableSpace(String s) throws IOException {

@Override
public AsyncLineageSubmission retrieveLineageSubmission(final String lineageIdentifier,
final NiFiUser user) {
final NiFiUser user) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public interface ProvenanceEventRecord {
*/
List<Long> getPreviousEventIds();

void setPreviousEventIds(List<Long> previousEventIds);

/**
* @return the time at which this Provenance Event was created, as the
* number of milliseconds since epoch
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.provenance;

package org.apache.nifi.graph;
import java.util.List;

/**
* This interface is meant to make it easier for anyone who wants to write components to target TinkerPop/OpenCypher
* client services only.
*/
public interface TinkerPopClientService extends GraphClientService {
public interface UpdateableProvenanceEventRecord extends ProvenanceEventRecord {

void setEventId(final long eventId);
void setPreviousEventIds(List<Long> previousEventIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* A Provenance Event that is used to replace another Provenance Event when authorizations
* are not granted for the original Provenance Event
*/
public class PlaceholderProvenanceEvent implements ProvenanceEventRecord {
public class PlaceholderProvenanceEvent implements UpdateableProvenanceEventRecord {
private final String componentId;
private final long eventId;
private long eventId;
private List<Long> previousEventIds;
private final long eventTime;
private final String flowFileUuid;
Expand All @@ -45,6 +45,11 @@ public long getEventId() {
return eventId;
}

@Override
public void setEventId(long eventId) {
this.eventId = eventId;
}

@Override
public List<Long> getPreviousEventIds() {
return previousEventIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Holder for provenance relevant information
*/
public class StandardProvenanceEventRecord implements ProvenanceEventRecord {
public class StandardProvenanceEventRecord implements UpdateableProvenanceEventRecord {

private final long eventTime;
private final long entryDate;
Expand Down Expand Up @@ -125,7 +125,8 @@ public long getStorageByteOffset() {
return storageByteOffset;
}

void setEventId(final long eventId) {
@Override
public void setEventId(final long eventId) {
this.eventId = eventId;
}

Expand Down Expand Up @@ -316,7 +317,8 @@ public int hashCode() {
}

return -37423 + 3 * componentId.hashCode() + (transitUri == null ? 0 : 41 * transitUri.hashCode())
+ (relationship == null ? 0 : 47 * relationship.hashCode()) + 44 * eventTypeCode
//+ (relationship == null ? 0 : 47 * relationship.hashCode())
+ 44 * eventTypeCode
+ 47 * getChildUuids().hashCode() + 47 * getParentUuids().hashCode();
}

Expand Down Expand Up @@ -363,10 +365,6 @@ public boolean equals(final Object obj) {
return false;
}

if (different(relationship, other.relationship)) {
return false;
}

return !(eventType == ProvenanceEventType.REPLAY && eventTime != other.getEventTime());
}

Expand Down Expand Up @@ -431,7 +429,7 @@ public String toString() {
+ ", uuid=" + uuid
+ ", fileSize=" + contentSize
+ ", componentId=" + componentId
+ ", componentType" + componentType
+ ", componentType=" + componentType
+ ", transitUri=" + transitUri
+ ", sourceSystemFlowFileIdentifier=" + sourceSystemFlowFileIdentifier
+ ", parentUuids=" + parentUuids
Expand Down Expand Up @@ -535,7 +533,6 @@ public Builder fromEvent(final ProvenanceEventRecord event) {
}

previousEventIds = event.getPreviousEventIds();

return this;
}

Expand Down
Loading

0 comments on commit 81d7061

Please sign in to comment.