public class RecordBinManager extends Object
Modifier and Type | Field and Description |
---|---|
private AtomicInteger |
binCount |
private ProcessContext |
context |
private Map<String,List<RecordBin>> |
groupBinMap |
private Lock |
lock |
private ComponentLog |
logger |
private AtomicLong |
maxBinAgeNanos |
private int |
maxBinCount |
private ProcessSessionFactory |
sessionFactory |
Constructor and Description |
---|
RecordBinManager(ProcessContext context,
ProcessSessionFactory sessionFactory,
ComponentLog logger) |
Modifier and Type | Method and Description |
---|---|
void |
add(String groupIdentifier,
FlowFile flowFile,
RecordReader reader,
ProcessSession session,
boolean block)
Adds the given flowFiles to the first available bin in which it fits for the given group or creates a new bin in the specified group if necessary.
|
int |
completeExpiredBins() |
int |
completeFullEnoughBins() |
void |
completeOldestBin() |
private RecordBinThresholds |
createThresholds(FlowFile flowfile) |
int |
getBinCount() |
private int |
handleCompletedBins(Predicate<RecordBin> completionTest,
String completionReason) |
void |
purge()
Must be called only when there are no active threads modifying the bins.
|
private void |
removeBins(String key,
List<RecordBin> bins) |
void |
setMaxBinAge(Long timePeriod,
TimeUnit timeUnit) |
private final ProcessContext context
private final ProcessSessionFactory sessionFactory
private final ComponentLog logger
private final int maxBinCount
private final AtomicLong maxBinAgeNanos
private final Lock lock
private final AtomicInteger binCount
public RecordBinManager(ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger)
public void purge()
public int getBinCount()
public void add(String groupIdentifier, FlowFile flowFile, RecordReader reader, ProcessSession session, boolean block) throws IOException
groupIdentifier
- the group to which the flow file belongs; can be nullflowFile
- flowFile to binreader
- RecordReader to use for reading FlowFilesession
- the ProcessSession to which the FlowFiles belongblock
- if another thread is already writing to the desired bin, passing true
for this parameter will block until the other thread(s) have finished so
that the records can still be added to the desired bin. Passing false
will result in moving on to another bin.IOException
- if there is an IO problem reading from the stream or writing to the streamprivate RecordBinThresholds createThresholds(FlowFile flowfile)
public void completeOldestBin() throws IOException
IOException
public int completeExpiredBins() throws IOException
IOException
public int completeFullEnoughBins() throws IOException
IOException
private int handleCompletedBins(Predicate<RecordBin> completionTest, String completionReason) throws IOException
IOException
Copyright © 2020 Apache NiFi Project. All rights reserved.