Package org.apache.nifi.io.nio.consumer
Class AbstractStreamConsumer
java.lang.Object
org.apache.nifi.io.nio.consumer.AbstractStreamConsumer
- All Implemented Interfaces:
StreamConsumer
-
Field Summary
Modifier and TypeFieldDescriptionprivate BufferPool
private final AtomicBoolean
private final BlockingQueue
<ByteBuffer> private final AtomicBoolean
private final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addFilledBuffer
(ByteBuffer buffer) Will be called by the thread that produces byte buffers with available data to be processed.final boolean
final String
getId()
Uniquely identifies the consumerfinal int
hashCode()
final boolean
If true signals the consumer is done consuming data and will not process any more buffers.protected void
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.final void
process()
Will be called by the thread that executes the consumption of data.protected abstract void
processBuffer
(ByteBuffer buffer) final void
setReturnBufferQueue
(BufferPool returnQueue) Will be called once just after construction.final void
Called once the end of the input stream is detectedfinal String
toString()
-
Field Details
-
uniqueId
-
bufferPool
-
filledBuffers
-
streamEnded
-
consumerEnded
-
-
Constructor Details
-
AbstractStreamConsumer
-
-
Method Details
-
setReturnBufferQueue
Description copied from interface:StreamConsumer
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!!!- Specified by:
setReturnBufferQueue
in interfaceStreamConsumer
- Parameters:
returnQueue
- pool of buffers to use
-
addFilledBuffer
Description copied from interface:StreamConsumer
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)- Specified by:
addFilledBuffer
in interfaceStreamConsumer
- Parameters:
buffer
- filled buffer
-
process
Description copied from interface:StreamConsumer
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.- Specified by:
process
in interfaceStreamConsumer
- Throws:
IOException
- if there is an issue processing
-
processBuffer
- Throws:
IOException
-
signalEndOfStream
public final void signalEndOfStream()Description copied from interface:StreamConsumer
Called once the end of the input stream is detected- Specified by:
signalEndOfStream
in interfaceStreamConsumer
-
onConsumerDone
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. -
isConsumerFinished
public final boolean isConsumerFinished()Description copied from interface:StreamConsumer
If true signals the consumer is done consuming data and will not process any more buffers.- Specified by:
isConsumerFinished
in interfaceStreamConsumer
- Returns:
- true if finished
-
getId
Description copied from interface:StreamConsumer
Uniquely identifies the consumer- Specified by:
getId
in interfaceStreamConsumer
- Returns:
- identifier of consumer
-
equals
-
hashCode
public final int hashCode() -
toString
-