Interface ProvenanceRepository

All Superinterfaces:
org.apache.nifi.provenance.ProvenanceEventRepository

public interface ProvenanceRepository extends org.apache.nifi.provenance.ProvenanceEventRepository
  • Method Details

    • initialize

      void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory, IdentifierLookup identifierLookup) throws IOException
      Performs any initialization needed. This should be called only by the framework.
      Parameters:
      eventReporter - to report to
      authorizer - the authorizer to use for authorizing individual events
      resourceFactory - the resource factory to use for generating Provenance Resource objects for authorization purposes
      identifierLookup - a mechanism for looking up identifiers in the flow
      Throws:
      IOException - if unable to initialize
    • getEvent

      org.apache.nifi.provenance.ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException
      Retrieves the Provenance Event with the given ID. The event will be returned only if the given user is authorized to access the event. Otherwise, an AccessDeniedException will be thrown. If the component for the event no longer exists, ResourceNotFoundException will be thrown.
      Parameters:
      id - to lookup
      user - The NiFi user that the event should be authorized against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      the Provenance Event Record with the given ID, if it exists, or null otherwise
      Throws:
      IOException - if failure while retrieving event
    • getEvents

      List<org.apache.nifi.provenance.ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords, NiFiUser user) throws IOException
      Returns a List of all ProvenanceEventRecords 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.
      Parameters:
      firstRecordId - id of the first record to retrieve
      maxRecords - maximum number of records to retrieve
      user - The NiFi user that the events should be authorized against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      records
      Throws:
      IOException - if error reading from repository
    • getProvenanceEventRepository

      org.apache.nifi.provenance.ProvenanceEventRepository getProvenanceEventRepository()
      Returns:
      the ProvenanceEventRepository backing this ProvenanceRepository
    • submitQuery

      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
      Parameters:
      query - to submit
      user - The NiFi User to authorize the events against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      an identifier that can be used to fetch the results at a later time
    • getLatestCachedEvents

      List<org.apache.nifi.provenance.ProvenanceEventRecord> getLatestCachedEvents(String componentId, int eventLimit) throws IOException
      Retrieves the Provenance Events that are cached for the most recent invocation of the given component.
      Parameters:
      componentId - the ID of the component
      eventLimit - the maximum number of events to return
      Returns:
      the list of events that are cached for the given component
      Throws:
      IOException - if unable to read from the repository
    • retrieveQuerySubmission

      QuerySubmission retrieveQuerySubmission(String queryIdentifier, NiFiUser user)
      Parameters:
      queryIdentifier - of the query
      user - The user who is retrieving the query. It can be null if the request was made by NiFi components internally where authorization is not required. If the queried user and the retrieved user do not match, AccessDeniedException will be thrown.
      Returns:
      the QueryResult associated with the given identifier, if the query has finished processing. If the query has not yet finished running, returns null
    • submitLineageComputation

      ComputeLineageSubmission submitLineageComputation(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. If the given user does not have authorization to view one of the events in the lineage, a placeholder event will be used instead that provides none of the event details except for the identifier of the component that emitted the Provenance Event. It is necessary to include this node in the lineage view so that the lineage makes sense, rather than showing disconnected graphs when the user is not authorized for all components' provenance events.
      Parameters:
      flowFileUuid - the UUID of the FlowFile for which the Lineage should be calculated
      user - The NiFi User to authorize the events against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      a ComputeLineageSubmission object that can be used to check if the computing is complete and if so get the results
    • submitLineageComputation

      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. If the given user does not have authorization to view one of the events in the lineage, a placeholder event will be used instead that provides none of the event details except for the identifier of the component that emitted the Provenance Event. It is necessary to include this node in the lineage view so that the lineage makes sense, rather than showing disconnected graphs when the user is not authorized for all components' provenance events. This method is preferred to submitLineageComputation(String, NiFiUser) because it is much more efficient, but the former may be used if a particular Event ID is not available.
      Parameters:
      eventId - the numeric ID of the event that the lineage is for
      user - The NiFi User to authorize the events against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      a ComputeLineageSubmission object that can be used to check if the computing is complete and if so get the results
    • retrieveLineageSubmission

      ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier, NiFiUser user)
      Parameters:
      lineageIdentifier - identifier of lineage to compute
      user - The user who is retrieving the lineage submission. It can be null if the request was made by NiFi components internally where authorization is not required. If the queried user and the retrieved user do not match, AccessDeniedException will be thrown.
      Returns:
      the ComputeLineageSubmission associated with the given identifier
    • submitExpandParents

      ComputeLineageSubmission submitExpandParents(long eventId, NiFiUser user)
      Submits a request to expand the parents of the event with the given id. If the given user is not authorized to access any event, a placeholder will be used instead that contains only the ID of the component that emitted the event.
      Parameters:
      eventId - the one-up id of the Event to expand
      user - The NiFi user to authorize events against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      a submission which can be checked for status
      Throws:
      IllegalArgumentException - if the given identifier identifies a Provenance Event that has a Type that is not expandable or if the identifier cannot be found
    • submitExpandChildren

      ComputeLineageSubmission submitExpandChildren(long eventId, NiFiUser user)
      Submits a request to expand the children of the event with the given id. If the given user is not authorized to access any event, a placeholder will be used instead that contains only the ID of the component that emitted the event.
      Parameters:
      eventId - the one-up id of the Event
      user - The NiFi user to authorize events against. It can be null if called by NiFi components internally where authorization is not required.
      Returns:
      a submission which can be checked for status
      Throws:
      IllegalArgumentException - if the given identifier identifies a Provenance Event that has a Type that is not expandable or if the identifier cannot be found
    • getSearchableFields

      List<SearchableField> getSearchableFields()
      Returns:
      a list of all fields that can be searched via the submitQuery(Query, NiFiUser) method
    • getSearchableAttributes

      List<SearchableField> getSearchableAttributes()
      Returns:
      a list of all FlowFile attributes that can be searched via the submitQuery(Query, NiFiUser) method
    • getContainerNames

      Set<String> getContainerNames()
      Returns:
      the names of all Containers that exist for this Provenance Repository
    • getContainerCapacity

      long getContainerCapacity(String containerName) throws IOException
      Parameters:
      containerName - name of container to check capacity on
      Returns:
      the maximum number of bytes that can be stored in the storage mechanism that backs the container with the given name
      Throws:
      IOException - if unable to check capacity
      IllegalArgumentException - if no container exists with the given name
    • getContainerFileStoreName

      String getContainerFileStoreName(String containerName)
      Returns the name of the FileStore that the given container is stored on, or null if not applicable or unable to determine the file store name
      Parameters:
      containerName - the name of the container
      Returns:
      the name of the FileStore
    • getContainerUsableSpace

      long getContainerUsableSpace(String containerName) throws IOException
      Parameters:
      containerName - to check space on
      Returns:
      the number of bytes available to be used used by the storage mechanism that backs the container with the given name
      Throws:
      IOException - if unable to check space
      IllegalArgumentException - if no container exists with the given name