java.lang.Object
org.apache.nifi.processor.util.bin.Bin

public class Bin extends Object
Note: Bin objects are NOT thread safe. If multiple threads access a Bin, the caller must synchronize access.
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
    • FRAGMENT_INDEX_ATTRIBUTE

      public static final String FRAGMENT_INDEX_ATTRIBUTE
    • session

      private final ProcessSession session
    • creationMomentEpochNs

      private final long creationMomentEpochNs
    • minimumSizeBytes

      private final long minimumSizeBytes
    • maximumSizeBytes

      private final long maximumSizeBytes
    • minimumEntries

      private volatile int minimumEntries
    • maximumEntries

      private volatile int maximumEntries
    • fileCountAttribute

      private final String fileCountAttribute
    • evictionReason

      private volatile EvictionReason evictionReason
    • binContents

      private final List<FlowFile> binContents
    • binIndexSet

      private final Set<String> binIndexSet
    • size

      private long size
    • successiveFailedOfferings

      private int successiveFailedOfferings
    • intPattern

      private static final Pattern intPattern
  • Constructor Details

    • Bin

      public Bin(ProcessSession session, long minSizeBytes, long maxSizeBytes, int minEntries, int maxEntries, String fileCountAttribute)
      Constructs a new bin
      Parameters:
      session - the session
      minSizeBytes - min bytes
      maxSizeBytes - max bytes
      minEntries - min entries
      maxEntries - max entries
      fileCountAttribute - num files
      Throws:
      IllegalArgumentException - if the min is not less than or equal to the max.
  • Method Details

    • getSession

      public ProcessSession getSession()
    • isFull

      public boolean isFull()
      Indicates whether the bin has enough items to be considered full. This is based on whether the current size of the bin is greater than the minimum size in bytes and based on having a number of successive unsuccessful attempts to add a new item (because it is so close to the max or the size of the objects being attempted do not favor tight packing)
      Returns:
      true if considered full; false otherwise
    • determineFullness

      public EvictionReason determineFullness()
    • isFullEnough

      public boolean isFullEnough()
      Indicates enough size exists to meet the minimum requirements
      Returns:
      true if full enough
    • isOlderThan

      public boolean isOlderThan(int duration, TimeUnit unit)
      Determines if this bin is older than the time specified.
      Parameters:
      duration - duration
      unit - unit
      Returns:
      true if this bin is older than the length of time given; false otherwise
    • isOlderThan

      public boolean isOlderThan(Bin other)
      Determines if this bin is older than the specified bin
      Parameters:
      other - other bin
      Returns:
      true if this is older than given bin
    • getEvictionReason

      public EvictionReason getEvictionReason()
    • setEvictionReason

      public void setEvictionReason(EvictionReason evictionReason)
    • offer

      public boolean offer(FlowFile flowFile, ProcessSession session)
      If this bin has enough room for the size of the given flow file then it is added otherwise it is not
      Parameters:
      flowFile - flowfile to offer
      session - the ProcessSession to which the FlowFile belongs
      Returns:
      true if added; false otherwise
    • toInteger

      public Integer toInteger(String value)
    • getContents

      public List<FlowFile> getContents()
      Returns:
      the underlying list of flow files within this bin
    • getBinAge

      public long getBinAge()