public abstract class AbstractStreamConsumer extends Object implements StreamConsumer
| Modifier and Type | Field and Description |
|---|---|
private BufferPool |
bufferPool |
private AtomicBoolean |
consumerEnded |
private BlockingQueue<ByteBuffer> |
filledBuffers |
private AtomicBoolean |
streamEnded |
private String |
uniqueId |
| Constructor and Description |
|---|
AbstractStreamConsumer(String id) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFilledBuffer(ByteBuffer buffer)
Will be called by the thread that produces byte buffers with available
data to be processed.
|
boolean |
equals(Object obj) |
String |
getId()
Uniquely identifies the consumer
|
int |
hashCode() |
boolean |
isConsumerFinished()
If true signals the consumer is done consuming data and will not process
any more buffers.
|
protected void |
onConsumerDone()
Convenience method that is called when the consumer is done processing
based on being told the signal is end of stream and has processed all
given buffers.
|
void |
process()
Will be called by the thread that executes the consumption of data.
|
protected abstract void |
processBuffer(ByteBuffer buffer) |
void |
setReturnBufferQueue(BufferPool returnQueue)
Will be called once just after construction.
|
void |
signalEndOfStream()
Called once the end of the input stream is detected
|
String |
toString() |
private final String uniqueId
private BufferPool bufferPool
private final BlockingQueue<ByteBuffer> filledBuffers
private final AtomicBoolean streamEnded
private final AtomicBoolean consumerEnded
public AbstractStreamConsumer(String id)
public final void setReturnBufferQueue(BufferPool returnQueue)
StreamConsumeraddFilledBuffer is called there should be an
associated add to this given queue. If not, buffers will run out and all
stream processing will halt. READ THIS!!!setReturnBufferQueue in interface StreamConsumerreturnQueue - pool of buffers to usepublic final void addFilledBuffer(ByteBuffer buffer)
StreamConsumeraddFilledBuffer in interface StreamConsumerbuffer - filled bufferpublic final void process()
throws IOException
StreamConsumerisConsumerFinished returns
true this method will likely do nothing.process in interface StreamConsumerIOException - if there is an issue processingprotected abstract void processBuffer(ByteBuffer buffer) throws IOException
IOExceptionpublic final void signalEndOfStream()
StreamConsumersignalEndOfStream in interface StreamConsumerprotected void onConsumerDone()
public final boolean isConsumerFinished()
StreamConsumerisConsumerFinished in interface StreamConsumerpublic final String getId()
StreamConsumergetId in interface StreamConsumerCopyright © 2023 Apache NiFi Project. All rights reserved.