Interface ResourceClaimManager


public interface ResourceClaimManager
Responsible for managing all ResourceClaims that are used in the application
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Decreases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count
    void
    drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements)
    Drains up to maxElements Content Claims from the internal queue of destructable content claims to the given destination so that they can be destroyed.
    void
    drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit)
    Drains up to maxElements Content Claims from the internal queue of destructable content claims to the given destination so that they can be destroyed.
    void
    Freezes the Resource Claim so that it can no longer be written to
    int
     
    getResourceClaim(String container, String section, String id)
    Returns the Resource Claim with the given id, container, and section, if one exists, null otherwise
    int
    Increases by 1 the count of how many FlowFiles hold a claim to a particular piece of FlowFile content and returns the new count
    int
    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
    Indicates whether or not the given Resource Claim is awaiting destruction
    void
    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
    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 claim
      section - of claim
      id - of claim
      lossTolerant - of claim
      writable - whether or not the claim should be made writable
      Returns:
      new claim
    • getResourceClaim

      ResourceClaim getResourceClaim(String container, String section, String id)
      Returns the Resource Claim with the given id, container, and section, if one exists, null otherwise
      Parameters:
      container - of claim
      section - of claim
      id - of claim
      Returns:
      the existing resource claim or null if none exists
    • getClaimantCount

      int getClaimantCount(ResourceClaim claim)
      Parameters:
      claim - to obtain reference count for
      Returns:
      the number of FlowFiles that hold a claim to a particular piece of FlowFile content
    • decrementClaimantCount

      int decrementClaimantCount(ResourceClaim claim)
      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

      int incrementClaimantCount(ResourceClaim claim)
      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

      int 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. 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 of true 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 increment
      newClaim - provides a hint that no other process can have access to this claim right now
      Returns:
      new claim count
    • markDestructable

      void markDestructable(ResourceClaim claim)
      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

      void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements)
      Drains up to maxElements Content Claims from the internal queue of destructable content claims to the given destination so that they can be destroyed.
      Parameters:
      destination - to drain to
      maxElements - max items to drain
    • drainDestructableClaims

      void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit)
      Drains up to maxElements Content Claims from the internal queue of destructable content claims to the given destination 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 given destination.
      Parameters:
      destination - to drain to
      maxElements - max items to drain
      timeout - maximum time to wait
      unit - unit of time to wait
    • purge

      void purge()
      Clears the manager's memory of any and all ResourceClaims that it knows about
    • freeze

      void freeze(ResourceClaim claim)
      Freezes the Resource Claim so that it can no longer be written to
      Parameters:
      claim - the resource claim to freeze
    • isDestructable

      boolean isDestructable(ResourceClaim claim)
      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