public class PersistentProvenanceRepository extends java.lang.Object implements ProvenanceRepository
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EVENT_CATEGORY |
static java.util.regex.Pattern |
INDEX_PATTERN |
static java.util.regex.Pattern |
LOG_FILENAME_PATTERN |
static int |
MAX_INDEXING_FAILURE_COUNT |
static int |
MAX_JOURNAL_ROLLOVER_RETRIES |
static int |
MAX_UNDELETED_QUERY_RESULTS |
static java.util.regex.Pattern |
NUMBER_PATTERN |
Constructor and Description |
---|
PersistentProvenanceRepository()
default no args constructor for service loading only.
|
PersistentProvenanceRepository(NiFiProperties nifiProperties) |
PersistentProvenanceRepository(RepositoryConfiguration configuration,
int rolloverCheckMillis) |
Modifier and Type | Method and Description |
---|---|
void |
authorize(ProvenanceEventRecord event,
NiFiUser user) |
void |
close()
Closes the repository, freeing any resources
|
protected IndexingAction |
createIndexingAction()
This method is protected and exists for testing purposes.
|
protected RecordWriter[] |
createWriters(RepositoryConfiguration config,
long initialRecordId) |
StandardProvenanceEventRecord.Builder |
eventBuilder()
Returns a
ProvenanceEventBuilder that is capable of building
ProvenanceEventRecord s |
java.util.List<ProvenanceEventRecord> |
filterUnauthorizedEvents(java.util.List<ProvenanceEventRecord> events,
NiFiUser user) |
protected java.util.List<java.io.File> |
filterUnavailableFiles(java.util.List<java.io.File> journalFiles) |
java.util.Collection<java.nio.file.Path> |
getAllLogFiles() |
RepositoryConfiguration |
getConfiguration() |
long |
getContainerCapacity(java.lang.String containerName) |
java.util.Set<java.lang.String> |
getContainerNames() |
long |
getContainerUsableSpace(java.lang.String containerName) |
ProvenanceEventRecord |
getEvent(long id)
Retrieves the Provenance Event with the given ID.
|
ProvenanceEventRecord |
getEvent(long id,
NiFiUser user) |
java.util.List<ProvenanceEventRecord> |
getEvents(long firstRecordId,
int maxRecords)
Returns a List of all
ProvenanceEventRecord s in the
repository starting with the given ID. |
java.util.List<ProvenanceEventRecord> |
getEvents(long firstRecordId,
int maxRecords,
NiFiUser user)
Returns a List of all
ProvenanceEventRecord s in the
repository starting with the given ID. |
protected IndexManager |
getIndexManager() |
protected int |
getJournalCount() |
int |
getMaxAttributeCharacters() |
java.lang.Long |
getMaxEventId() |
ProvenanceEventRepository |
getProvenanceEventRepository() |
protected long |
getRolloverRetryMillis() |
java.util.List<SearchableField> |
getSearchableAttributes() |
java.util.List<SearchableField> |
getSearchableFields() |
long |
getSize(java.util.List<java.io.File> logFiles,
long timeCutoff)
Returns the size, in bytes, of the Repository storage
|
void |
initialize(EventReporter eventReporter,
Authorizer authorizer,
ProvenanceAuthorizableFactory resourceFactory,
IdentifierLookup idLookup)
Performs any initialization needed.
|
boolean |
isAuthorized(ProvenanceEventRecord event,
NiFiUser user) |
boolean |
isShutdownComplete() |
protected java.util.Set<java.io.File> |
recoverJournalFiles() |
void |
registerEvent(ProvenanceEventRecord event)
Adds the given event to the repository and returns a new event for which
the event id has been populated.
|
void |
registerEvents(java.lang.Iterable<ProvenanceEventRecord> events)
Adds the given events to the repository.
|
java.util.Set<ProvenanceEventRecord> |
replaceUnauthorizedWithPlaceholders(java.util.Set<ProvenanceEventRecord> events,
NiFiUser user) |
AsyncLineageSubmission |
retrieveLineageSubmission(java.lang.String lineageIdentifier,
NiFiUser user) |
QuerySubmission |
retrieveQuerySubmission(java.lang.String queryIdentifier,
NiFiUser user) |
AsyncLineageSubmission |
submitExpandChildren(long eventId,
NiFiUser user)
Submits a request to expand the children of the event with the given id.
|
AsyncLineageSubmission |
submitExpandParents(long eventId,
NiFiUser user)
Submits a request to expand the parents of the event with the given id.
|
ComputeLineageSubmission |
submitLineageComputation(long eventId,
NiFiUser user)
Submits a Lineage Computation to be completed and returns the
AsynchronousLineageResult that indicates the status of the request and
the results, if the computation is complete.
|
AsyncLineageSubmission |
submitLineageComputation(java.lang.String flowFileUuid,
NiFiUser user)
Submits a Lineage Computation to be completed and returns the
AsynchronousLineageResult that indicates the status of the request and
the results, if the computation is complete.
|
QuerySubmission |
submitQuery(Query query,
NiFiUser user)
Submits an asynchronous request to process the given query, returning an
identifier that can be used to fetch the results at a later time
|
void |
waitForRollover()
Blocks the calling thread until the repository rolls over.
|
public static final java.lang.String EVENT_CATEGORY
public static final java.util.regex.Pattern NUMBER_PATTERN
public static final java.util.regex.Pattern INDEX_PATTERN
public static final java.util.regex.Pattern LOG_FILENAME_PATTERN
public static final int MAX_UNDELETED_QUERY_RESULTS
public static final int MAX_INDEXING_FAILURE_COUNT
public static final int MAX_JOURNAL_ROLLOVER_RETRIES
public PersistentProvenanceRepository()
public PersistentProvenanceRepository(NiFiProperties nifiProperties) throws java.io.IOException
java.io.IOException
public PersistentProvenanceRepository(RepositoryConfiguration configuration, int rolloverCheckMillis) throws java.io.IOException
java.io.IOException
protected IndexManager getIndexManager()
public void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory, IdentifierLookup idLookup) throws java.io.IOException
ProvenanceRepository
initialize
in interface ProvenanceRepository
eventReporter
- to report toauthorizer
- the authorizer to use for authorizing individual eventsresourceFactory
- the resource factory to use for generating Provenance Resource objects for authorization purposesidLookup
- a mechanism for looking up identifiers in the flowjava.io.IOException
- if unable to initializeprotected RecordWriter[] createWriters(RepositoryConfiguration config, long initialRecordId) throws java.io.IOException
java.io.IOException
public int getMaxAttributeCharacters()
public StandardProvenanceEventRecord.Builder eventBuilder()
ProvenanceEventRepository
ProvenanceEventBuilder
that is capable of building
ProvenanceEventRecord
seventBuilder
in interface ProvenanceEventRepository
public void registerEvent(ProvenanceEventRecord event)
ProvenanceEventRepository
registerEvent
in interface ProvenanceEventRepository
event
- to registerpublic void registerEvents(java.lang.Iterable<ProvenanceEventRecord> events)
ProvenanceEventRepository
This interface makes no assumptions about whether or not the registration of the Collection are atomic. This detail is implementation-specific.
registerEvents
in interface ProvenanceEventRepository
events
- to registerpublic boolean isAuthorized(ProvenanceEventRecord event, NiFiUser user)
public void authorize(ProvenanceEventRecord event, NiFiUser user)
public java.util.List<ProvenanceEventRecord> filterUnauthorizedEvents(java.util.List<ProvenanceEventRecord> events, NiFiUser user)
public java.util.Set<ProvenanceEventRecord> replaceUnauthorizedWithPlaceholders(java.util.Set<ProvenanceEventRecord> events, NiFiUser user)
public java.util.List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords) throws java.io.IOException
ProvenanceEventRepository
ProvenanceEventRecord
s in the
repository starting with the given ID. The first ID in the repository
will always be 0 or higher. This method performs no authorization of
the events.getEvents
in interface ProvenanceEventRepository
firstRecordId
- id of the first record to retrievemaxRecords
- maximum number of records to retrievejava.io.IOException
- if error reading from repositorypublic java.util.List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords, NiFiUser user) throws java.io.IOException
ProvenanceRepository
ProvenanceEventRecord
s in the
repository starting with the given ID. The first ID in the repository
will always be 0 or higher. Each event that is found will be authorized
against the given NiFiUser. If the user does not have authorization for
the event, the event will not be returned.getEvents
in interface ProvenanceRepository
firstRecordId
- id of the first record to retrievemaxRecords
- maximum number of records to retrieveuser
- the NiFi user that the events should be authorized againstjava.io.IOException
- if error reading from repositorypublic RepositoryConfiguration getConfiguration()
public java.util.Set<java.lang.String> getContainerNames()
getContainerNames
in interface ProvenanceRepository
public long getContainerCapacity(java.lang.String containerName) throws java.io.IOException
getContainerCapacity
in interface ProvenanceRepository
containerName
- name of container to check capacity onjava.io.IOException
- if unable to check capacitypublic long getContainerUsableSpace(java.lang.String containerName) throws java.io.IOException
getContainerUsableSpace
in interface ProvenanceRepository
containerName
- to check space onjava.io.IOException
- if unable to check spacepublic void close() throws java.io.IOException
ProvenanceEventRepository
close
in interface ProvenanceEventRepository
java.io.IOException
- if failure closing repositorypublic boolean isShutdownComplete()
public long getSize(java.util.List<java.io.File> logFiles, long timeCutoff)
logFiles
- the log files to considertimeCutoff
- if a log file's last modified date is before
timeCutoff, it will be skippedpublic void waitForRollover()
protected int getJournalCount()
protected long getRolloverRetryMillis()
protected java.util.Set<java.io.File> recoverJournalFiles() throws java.io.IOException
java.io.IOException
protected java.util.List<java.io.File> filterUnavailableFiles(java.util.List<java.io.File> journalFiles)
protected IndexingAction createIndexingAction()
public java.util.List<SearchableField> getSearchableFields()
getSearchableFields
in interface ProvenanceRepository
ProvenanceRepository.submitQuery(Query, NiFiUser)
methodpublic java.util.List<SearchableField> getSearchableAttributes()
getSearchableAttributes
in interface ProvenanceRepository
ProvenanceRepository.submitQuery(Query, NiFiUser)
methodpublic QuerySubmission submitQuery(Query query, NiFiUser user)
ProvenanceRepository
submitQuery
in interface ProvenanceRepository
query
- to submituser
- the NiFi User to authorize the events againstpublic ComputeLineageSubmission submitLineageComputation(long eventId, NiFiUser user)
ProvenanceRepository
ProvenanceRepository.submitLineageComputation(String, NiFiUser)
because
it is much more efficient, but the former may be used if a particular Event ID is not
available.submitLineageComputation
in interface ProvenanceRepository
eventId
- the numeric ID of the event that the lineage is foruser
- the NiFi User to authorize events againstComputeLineageSubmission
object that can be used to
check if the computing is complete and if so get the resultspublic AsyncLineageSubmission submitLineageComputation(java.lang.String flowFileUuid, NiFiUser user)
ProvenanceRepository
submitLineageComputation
in interface ProvenanceRepository
flowFileUuid
- the UUID of the FlowFile for which the Lineage should
be calculateduser
- the NiFi User to authorize events againstComputeLineageSubmission
object that can be used to
check if the computing is complete and if so get the resultspublic AsyncLineageSubmission submitExpandChildren(long eventId, NiFiUser user)
ProvenanceRepository
submitExpandChildren
in interface ProvenanceRepository
eventId
- the one-up id of the Eventuser
- the NiFi user to authorize events againstpublic AsyncLineageSubmission submitExpandParents(long eventId, NiFiUser user)
ProvenanceRepository
submitExpandParents
in interface ProvenanceRepository
eventId
- the one-up id of the Event to expanduser
- the NiFi user to authorize events againstpublic AsyncLineageSubmission retrieveLineageSubmission(java.lang.String lineageIdentifier, NiFiUser user)
retrieveLineageSubmission
in interface ProvenanceRepository
lineageIdentifier
- identifier of lineage to computeuser
- the user who is retrieving the lineage submissionComputeLineageSubmission
associated with the given
identifierpublic QuerySubmission retrieveQuerySubmission(java.lang.String queryIdentifier, NiFiUser user)
retrieveQuerySubmission
in interface ProvenanceRepository
queryIdentifier
- of the queryuser
- the user who is retrieving the querynull
public ProvenanceEventRecord getEvent(long id) throws java.io.IOException
ProvenanceEventRepository
getEvent
in interface ProvenanceEventRepository
id
- to lookupnull
otherwisejava.io.IOException
- if failure while retrieving eventpublic ProvenanceEventRecord getEvent(long id, NiFiUser user) throws java.io.IOException
getEvent
in interface ProvenanceRepository
java.io.IOException
public ProvenanceEventRepository getProvenanceEventRepository()
getProvenanceEventRepository
in interface ProvenanceRepository
ProvenanceEventRepository
backing this ProvenanceRepositorypublic java.util.Collection<java.nio.file.Path> getAllLogFiles()
public java.lang.Long getMaxEventId()
getMaxEventId
in interface ProvenanceEventRepository