Interface FlowFileRepository
- All Superinterfaces:
AutoCloseable,Closeable
-
Method Summary
Modifier and TypeMethodDescriptiondefault Set<ResourceClaim> Returns the set of Resource Claims that are referenced by FlowFiles that have been "orphaned" because they belong to FlowFile Queues/Connections that did not exist in the flow when NiFi startedfindQueuesWithFlowFiles(FlowFileSwapManager flowFileSwapManager) Searches through the repository to find the ID's of all FlowFile Queues that currently have data queueddefault Map<ResourceClaim, Set<ResourceClaimReference>> findResourceClaimReferences(Set<ResourceClaim> resourceClaims, FlowFileSwapManager swapManager) Scans the FlowFile Repository to locate any FlowFiles that reference the given Resource Claims.Returns the name of the FileStore that the repository is stored on, ornullif not applicable or unable to determine the file store namelonglonglonglongvoidinitialize(ResourceClaimManager claimManager) Initializes the Content Repository, providing to it the ContentClaimManager that is to be used for interacting with Content ClaimsbooleanisValidSwapLocationSuffix(String swapLocationSuffix) Determines whether or not the given swap location suffix is a valid, known location according to this FlowFileRepository.booleanlongloadFlowFiles(QueueProvider queueProvider) Loads all flow files found within the repository, establishes the content claims and their reference countvoidswapFlowFilesIn(String swapLocation, List<FlowFileRecord> flowFileRecords, FlowFileQueue flowFileQueue) Updates the Repository to indicate that the given FlowFileRecords were Swapped In to memoryvoidswapFlowFilesOut(List<FlowFileRecord> swappedOut, FlowFileQueue flowFileQueue, String swapLocation) Updates the Repository to indicate that the given FlowFileRecords were Swapped Out of memoryvoidupdateMaxFlowFileIdentifier(long maxId) Notifies the FlowFile Repository that the given identifier has been identified as the maximum value that has been encountered for an 'external' (swapped out) FlowFile.voidupdateRepository(Collection<RepositoryRecord> records) Updates the repository with the given RepositoryRecords.
-
Method Details
-
initialize
Initializes the Content Repository, providing to it the ContentClaimManager that is to be used for interacting with Content Claims- Parameters:
claimManager- for handling claims- Throws:
IOException- if unable to initialize repository
-
getStorageCapacity
- Returns:
- the maximum number of bytes that can be stored in the underlying storage mechanism
- Throws:
IOException- if computing capacity fails
-
getUsableStorageSpace
- Returns:
- the number of bytes currently available for use by the underlying storage mechanism
- Throws:
IOException- if computing usable space fails
-
getFileStoreName
String getFileStoreName()Returns the name of the FileStore that the repository is stored on, ornullif not applicable or unable to determine the file store name- Returns:
- the name of the FileStore
-
updateRepository
Updates the repository with the given RepositoryRecords.- Parameters:
records- the records to update the repository with- Throws:
IOException- if update fails
-
loadFlowFiles
Loads all flow files found within the repository, establishes the content claims and their reference count- Parameters:
queueProvider- the provider of FlowFile Queues into which the FlowFiles should be enqueued- Returns:
- index of highest flow file identifier
- Throws:
IOException- if load fails
-
findQueuesWithFlowFiles
Searches through the repository to find the ID's of all FlowFile Queues that currently have data queued- Returns:
- the set of all FlowFileQueue identifiers for which a FlowFile is queued
- Throws:
IOException- if unable to read from the FlowFile Repository
-
isVolatile
boolean isVolatile()- Returns:
trueif the Repository is volatile (i.e., its data is lost upon application restart),falseotherwise
-
getNextFlowFileSequence
long getNextFlowFileSequence()- Returns:
- the next ID in sequence for creating
FlowFiles.
-
getMaxFlowFileIdentifier
- Returns:
- the max ID of all
FlowFiles that currently exist in the repository. - Throws:
IOException- if computing max identifier fails
-
updateMaxFlowFileIdentifier
void updateMaxFlowFileIdentifier(long maxId) Notifies the FlowFile Repository that the given identifier has been identified as the maximum value that has been encountered for an 'external' (swapped out) FlowFile.- Parameters:
maxId- the max id of any FlowFile encountered
-
swapFlowFilesOut
void swapFlowFilesOut(List<FlowFileRecord> swappedOut, FlowFileQueue flowFileQueue, String swapLocation) throws IOException Updates the Repository to indicate that the given FlowFileRecords were Swapped Out of memory- Parameters:
swappedOut- the FlowFiles that were swapped out of memoryflowFileQueue- the queue that the FlowFiles belong toswapLocation- the location to which the FlowFiles were swapped- Throws:
IOException- if swap fails
-
swapFlowFilesIn
void swapFlowFilesIn(String swapLocation, List<FlowFileRecord> flowFileRecords, FlowFileQueue flowFileQueue) throws IOException Updates the Repository to indicate that the given FlowFileRecords were Swapped In to memory- Parameters:
swapLocation- the location (e.g., a filename) from which FlowFiles were recoveredflowFileRecords- the records that were swapped inflowFileQueue- the queue that the FlowFiles belong to- Throws:
IOException- if swap fails
-
isValidSwapLocationSuffix
Determines whether or not the given swap location suffix is a valid, known location according to this FlowFileRepository. Note that while the
swapFlowFilesIn(String, List, FlowFileQueue)andswapFlowFilesOut(List, FlowFileQueue, String)methods expect a full "swap location" this method expects only the "suffix" of a swap location. For example, if the location points to a file, this method would expect only the filename, not the full path.This method differs from the others because the other methods want to store the swap location or recover from a given location. However, this method is used to verify that the location is known. If for any reason, NiFi is stopped, its FlowFile Repository relocated to a new location (for example, a different disk partition), and restarted, the swap location would not match if we used the full location. Therefore, by using only the "suffix" (i.e. the filename for a file-based implementation), we can avoid worrying about relocation.
- Parameters:
swapLocationSuffix- the suffix of the location to check- Returns:
trueif the swap location is known and valid,falseotherwise
-
findResourceClaimReferences
default Map<ResourceClaim,Set<ResourceClaimReference>> findResourceClaimReferences(Set<ResourceClaim> resourceClaims, FlowFileSwapManager swapManager) throws IOException Scans the FlowFile Repository to locate any FlowFiles that reference the given Resource Claims. If the FlowFile Repository does not implement this capability, it will return
null.- Parameters:
resourceClaims- the resource claims whose references should be foundswapManager- the swap manager to use for scanning swap files- Returns:
- a Mapping of Resource Claim to a representation of the FlowFiles/Swap Files that reference those Resource Claims
- Throws:
IOException- if an IO failure occurs when attempting to find references
-
findOrphanedResourceClaims
Returns the set of Resource Claims that are referenced by FlowFiles that have been "orphaned" because they belong to FlowFile Queues/Connections that did not exist in the flow when NiFi started- Returns:
- the set of orphaned Resource Claims
-