Interface ContentRepository
public interface ContentRepository
Defines the capabilities of a content repository. Append options are not
available on the methods but a merge capability is provided which between
that and creating new claims a merge is available.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Performs any cleanup actions that may need to be taken upon system restart.clone
(ContentClaim original, boolean lossTolerant) Clones the content for the given content claim and returns content claim of the new objectcreate
(boolean lossTolerant) Creates a new content claimint
Reduces the number of claimants for the given claim.long
exportTo
(ContentClaim claim, OutputStream destination) Exports the content of the given claim to the given destination.long
exportTo
(ContentClaim claim, OutputStream destination, long offset, long length) Exports a subset of the content of the given claim, starting at offset and copying length bytes, to the given destination.long
exportTo
(ContentClaim claim, Path destination, boolean append) Exports the content of the given claim to the given destination.long
exportTo
(ContentClaim claim, Path destination, boolean append, long offset, long length) Exports the content of the given claim to the given destination.default Set
<ResourceClaim> getActiveResourceClaims
(String containerName) Optional operation that returns a List of all Resource Claims that exist in the given Container that are considered "active" (i.e., not archived)int
getClaimantCount
(ContentClaim claim) Obtains the current number of claimants for the given claimlong
getContainerCapacity
(String containerName) getContainerFileStoreName
(String containerName) Returns the name of the FileStore that the given container is stored on, ornull
if not applicable or unable to determine the file store namelong
getContainerUsableSpace
(String containerName) long
importFrom
(InputStream content, ContentClaim claim) Imports content from the given stream creating a new content object and claim within the repository.long
importFrom
(Path content, ContentClaim claim) Imports content from the given path creating a new content object and claim within the repository.int
Increments the number of claimants for the given claimvoid
initialize
(ContentRepositoryContext context) Initializes the Content Repository, providing to it the ContentRepositoryContext.boolean
isAccessible
(ContentClaim contentClaim) default boolean
Indicates whether or not the repository supports obtaining a list of active Resource Claims via thegetActiveResourceClaims(String)
methoddefault boolean
Indicates whether or not this Content Repository supports obtaining an InputStream for an entire Resource Claim.void
purge()
Purges the contents of the repository, as if the repository were newly created.read
(ContentClaim claim) Provides access to the input stream for the given claimread
(ResourceClaim claim) Provides access ot the input stream for the entire Resource Claimboolean
remove
(ContentClaim claim) Removes the content indicated by the given claimvoid
shutdown()
Shuts down the Content Repository, freeing any resources that may be held.long
size
(ContentClaim claim) long
size
(ResourceClaim claim) write
(ContentClaim claim) Obtains an OutputStream to the content for the given claim.
-
Method Details
-
initialize
Initializes the Content Repository, providing to it the ContentRepositoryContext.- Parameters:
context
- to initialize repository- Throws:
IOException
- if unable to init
-
shutdown
void shutdown()Shuts down the Content Repository, freeing any resources that may be held. This is called when an administrator shuts down NiFi. -
getContainerNames
- Returns:
- the names of all Containers that exist for this Content Repository
-
getContainerCapacity
- 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 capacityIllegalArgumentException
- if no container exists with the given name
-
getContainerUsableSpace
- 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 spaceIllegalArgumentException
- if no container exists with the given name
-
getContainerFileStoreName
Returns the name of the FileStore that the given container is stored on, ornull
if not applicable or unable to determine the file store name- Parameters:
containerName
- the name of the container- Returns:
- the name of the FileStore
-
create
Creates a new content claim- Parameters:
lossTolerant
- indicates whether the content for the new claim is loss tolerant. If true the repository might choose more volatile storage options which could increase performance for a tradeoff with reliability- Returns:
- newly created claim
- Throws:
IOException
- if unable to create claim
-
incrementClaimaintCount
Increments the number of claimants for the given claim- Parameters:
claim
- to increment- Returns:
- the number of claimants after incrementing
-
getClaimantCount
Obtains the current number of claimants for the given claim- Parameters:
claim
- to get count of- Returns:
- the number of claimants
-
decrementClaimantCount
Reduces the number of claimants for the given claim. Even if the given claim is null or content cannot be found or removed no exception will be thrown.- Parameters:
claim
- to decrement- Returns:
- new claimant count for the given claim
-
remove
Removes the content indicated by the given claim- Parameters:
claim
- to remove- Returns:
- a boolean indicating whether or not the destruction of the claim was successful
-
clone
Clones the content for the given content claim and returns content claim of the new object- Parameters:
original
- to clonelossTolerant
- if can be place in a loss tolerant repository- Returns:
- new claim
- Throws:
IOException
- if an IO error occurs. Any content written to the new destination prior to the error will be destroyed
-
importFrom
Imports content from the given path creating a new content object and claim within the repository.- Parameters:
content
- to import fromclaim
- the claim to write imported content to- Returns:
- the size of the claim
- Throws:
IOException
- if failure to read given content
-
importFrom
Imports content from the given stream creating a new content object and claim within the repository.- Parameters:
content
- to import fromclaim
- the claim to write imported content to- Returns:
- the size of the claim
- Throws:
IOException
- if unable to read content
-
exportTo
Exports the content of the given claim to the given destination.- Parameters:
claim
- to export fromdestination
- where to export dataappend
- if true appends to the destination; false overwrites- Returns:
- the size of the destination or the claim
- Throws:
IOException
- if an IO error occurs. The state of the content for the given destination is unknown and callers should consider whether they should clean up any partially created paths
-
exportTo
long exportTo(ContentClaim claim, Path destination, boolean append, long offset, long length) throws IOException Exports the content of the given claim to the given destination.- Parameters:
claim
- to export fromdestination
- where to export dataappend
- if true appends to the destination; false overwritesoffset
- the offset at which the claim should start being copiedlength
- the number of bytes to copy- Returns:
- the size of the destination or the claim
- Throws:
IOException
- if an IO error occurs. The state of the content for the given destination is unknown and callers should consider whether they should clean up any partially created paths
-
exportTo
Exports the content of the given claim to the given destination.- Parameters:
claim
- to export fromdestination
- where to export data- Returns:
- the size of the claim
- Throws:
IOException
- if an IO error occurs.
-
exportTo
long exportTo(ContentClaim claim, OutputStream destination, long offset, long length) throws IOException Exports a subset of the content of the given claim, starting at offset and copying length bytes, to the given destination.- Parameters:
claim
- to export fromdestination
- where to export dataoffset
- the offset into the claim at which the copy should beginlength
- the number of bytes to copy- Returns:
- the number of bytes copied
- Throws:
IOException
- if an IO error occurs.
-
size
- Parameters:
claim
- to get size of- Returns:
- size in bytes of content for given claim
- Throws:
IOException
- if size check failed
-
size
- Parameters:
claim
- to get size of- Returns:
- size in bytes of the file/object backing the given resource claim, or 0 if this operation is not supported by the implementation
- Throws:
IOException
- if size check failed
-
read
Provides access to the input stream for the given claim- Parameters:
claim
- to read from- Returns:
- InputStream over the content of the given claim
- Throws:
IOException
- if unable to read
-
read
Provides access ot the input stream for the entire Resource Claim- Parameters:
claim
- the resource claim to read from- Returns:
- InputStream over the content of the entire Resource Claim
- Throws:
IOException
- if unable to read
-
isResourceClaimStreamSupported
default boolean isResourceClaimStreamSupported()Indicates whether or not this Content Repository supports obtaining an InputStream for an entire Resource Claim. If this method returnsfalse
, theread(ResourceClaim)
should not be called and insteadread(ContentClaim)
should always be used- Returns:
true
if reading an entire Resource Claim is allowed,false
otherwise
-
write
Obtains an OutputStream to the content for the given claim.- Parameters:
claim
- to write to- Returns:
- the stream to write to
- Throws:
IOException
- if unable to obtain stream
-
purge
void purge()Purges the contents of the repository, as if the repository were newly created. -
cleanup
void cleanup()Performs any cleanup actions that may need to be taken upon system restart. For example, if content was partially written to the repository before the restart, the repository is given a chance to handle this data -
isAccessible
- Parameters:
contentClaim
- the Content Claim to check- Returns:
- Returns a boolean indicating whether or not the content specified
by the given claim can be read, regardless of whether the content has
been archived or not. If the ContentRepository does not implement
archiving capabilities, this method will return
false
- Throws:
IOException
- if unable to determine accessibility
-
getActiveResourceClaims
Optional operation that returns a List of all Resource Claims that exist in the given Container that are considered "active" (i.e., not archived)- Parameters:
containerName
- the name of the container- Returns:
- a List of all Resource Claims that exist in the given Container
- Throws:
IOException
- if unable to obtain a listing due to an IO failureUnsupportedOperationException
- if this repository does not implement this capability.- See Also:
-
isActiveResourceClaimsSupported
default boolean isActiveResourceClaimsSupported()Indicates whether or not the repository supports obtaining a list of active Resource Claims via thegetActiveResourceClaims(String)
method- Returns:
true
if the operation is supported,false
otherwise
-