Package org.apache.nifi.io.nio.consumer
Interface StreamConsumer
- All Known Implementing Classes:
AbstractStreamConsumer
public interface StreamConsumer
A StreamConsumer must be thread safe. It may be accessed concurrently by a
thread providing data to process and another thread that is processing that
data.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilledBuffer
(ByteBuffer buffer) Will be called by the thread that produces byte buffers with available data to be processed.getId()
Uniquely identifies the consumerboolean
If true signals the consumer is done consuming data and will not process any more buffers.void
process()
Will be called by the thread that executes the consumption of data.void
setReturnBufferQueue
(BufferPool returnQueue) Will be called once just after construction.void
Called once the end of the input stream is detected
-
Method Details
-
setReturnBufferQueue
Will be called once just after construction. It provides the queue to which processed and emptied and cleared buffers must be returned. For each timeaddFilledBuffer
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!!!- Parameters:
returnQueue
- pool of buffers to use
-
addFilledBuffer
Will be called by the thread that produces byte buffers with available data to be processed. If the consumer is finished this should simply return the given buffer to the return buffer queue (after it is cleared)- Parameters:
buffer
- filled buffer
-
process
Will be called by the thread that executes the consumption of data. May be called many times though onceisConsumerFinished
returns true this method will likely do nothing.- Throws:
IOException
- if there is an issue processing
-
signalEndOfStream
void signalEndOfStream()Called once the end of the input stream is detected -
isConsumerFinished
boolean isConsumerFinished()If true signals the consumer is done consuming data and will not process any more buffers.- Returns:
- true if finished
-
getId
String getId()Uniquely identifies the consumer- Returns:
- identifier of consumer
-