Interface ResourceClaimManager
public interface ResourceClaimManager
Responsible for managing all ResourceClaims that are used in the application
-
Method Summary
Modifier and TypeMethodDescriptionint
Decreases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new countvoid
drainDestructableClaims
(Collection<ResourceClaim> destination, int maxElements) Drains up tomaxElements
Content Claims from the internal queue of destructable content claims to the givendestination
so that they can be destroyed.void
drainDestructableClaims
(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit) Drains up tomaxElements
Content Claims from the internal queue of destructable content claims to the givendestination
so that they can be destroyed.void
freeze
(ResourceClaim claim) Freezes the Resource Claim so that it can no longer be written toint
getClaimantCount
(ResourceClaim claim) getResourceClaim
(String container, String section, String id) Returns the Resource Claim with the given id, container, and section, if one exists,null
otherwiseint
Increases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new countint
incrementClaimantCount
(ResourceClaim claim, boolean newClaim) Increases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count.boolean
isDestructable
(ResourceClaim claim) Indicates whether or not the given Resource Claim is awaiting destructionvoid
markDestructable
(ResourceClaim claim) Indicates that the given ResourceClaim can now be destroyed by the appropriate Content Repository.newResourceClaim
(String container, String section, String id, boolean lossTolerant, boolean writable) Creates a new Resource Claim with the given id, container, section, and loss tolerance.void
purge()
Clears the manager's memory of any and all ResourceClaims that it knows about
-
Method Details
-
newResourceClaim
ResourceClaim newResourceClaim(String container, String section, String id, boolean lossTolerant, boolean writable) Creates a new Resource Claim with the given id, container, section, and loss tolerance.- Parameters:
container
- of claimsection
- of claimid
- of claimlossTolerant
- of claimwritable
- whether or not the claim should be made writable- Returns:
- new claim
-
getResourceClaim
Returns the Resource Claim with the given id, container, and section, if one exists,null
otherwise- Parameters:
container
- of claimsection
- of claimid
- of claim- Returns:
- the existing resource claim or
null
if none exists
-
getClaimantCount
- Parameters:
claim
- to obtain reference count for- Returns:
- the number of FlowFiles that hold a claim to a particular piece of FlowFile content
-
decrementClaimantCount
Decreases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count- Parameters:
claim
- to decrement claimants on- Returns:
- new claimant count
-
incrementClaimantCount
Increases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count- Parameters:
claim
- to increment claims on- Returns:
- new claimant count
-
incrementClaimantCount
Increases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count. If it is known that the Content Claim whose count is being incremented is a newly created ResourceClaim, this method should be called with a value oftrue
as the second argument, as it may allow the manager to optimize its tasks, knowing that the Content Claim cannot be referenced by any other component- Parameters:
claim
- to incrementnewClaim
- provides a hint that no other process can have access to this claim right now- Returns:
- new claim count
-
markDestructable
Indicates that the given ResourceClaim can now be destroyed by the appropriate Content Repository. This should be done only after it is guaranteed that the FlowFile Repository has been synchronized with its underlying storage component. This way, we avoid the following sequence of events:- FlowFile Repository is updated to indicate that FlowFile F no longer depends on ResourceClaim C
- ResourceClaim C is no longer needed and is destroyed
- The Operating System crashes or there is a power failure
- Upon restart, the FlowFile Repository was not synchronized with its underlying storage mechanism and as such indicates that FlowFile F needs ResourceClaim C.
- Since ResourceClaim C has already been destroyed, it is inaccessible, and FlowFile F's Content is not found, so the FlowFile is removed, resulting in data loss.
Using this method of marking the ResourceClaim as destructable only when the FlowFile repository has been synced with the underlying storage mechanism, we can ensure that on restart, we will not point to this unneeded claim. As such, it is now safe to destroy the contents.
- Parameters:
claim
- to mark as now destructable
-
drainDestructableClaims
Drains up tomaxElements
Content Claims from the internal queue of destructable content claims to the givendestination
so that they can be destroyed.- Parameters:
destination
- to drain tomaxElements
- max items to drain
-
drainDestructableClaims
void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit) Drains up tomaxElements
Content Claims from the internal queue of destructable content claims to the givendestination
so that they can be destroyed. If no ResourceClaim is ready to be destroyed at this time, will wait up to the specified amount of time before returning. If, after the specified amount of time, there is still no ResourceClaim ready to be destroyed, the method will return without having added anything to the givendestination
.- Parameters:
destination
- to drain tomaxElements
- max items to draintimeout
- maximum time to waitunit
- unit of time to wait
-
purge
void purge()Clears the manager's memory of any and all ResourceClaims that it knows about -
freeze
Freezes the Resource Claim so that it can no longer be written to- Parameters:
claim
- the resource claim to freeze
-
isDestructable
Indicates whether or not the given Resource Claim is awaiting destruction- Parameters:
claim
- the resource claim- Returns:
true
if the Resource Claim is awaiting destruction,false
otherwise
-