RecordQueue — FIFO Queue of Buffered Stamped Records
RecordQueue
is a FIFO queue of StampedRecords from a Kafka partition (associated with a SourceNode).
RecordQueue
is created along with a StreamTask exclusively (for every partition assigned).
RecordQueue
acts as a buffer of Kafka ConsumerRecords.
Note
|
StreamTask uses a PartitionGroup to manage the RecordQueues per partition assigned.
|
RecordQueue
defines the UNKNOWN constant to be ConsumerRecord.NO_TIMESTAMP
.
Tip
|
Enable Add the following line to
Refer to Application Logging Using log4j. |
Creating RecordQueue Instance
RecordQueue
takes the following to be created:
-
Kafka TopicPartition
RecordQueue
initializes the internal properties.
Adding Kafka ConsumerRecords (as StampedRecords) — addRawRecords
Method
int addRawRecords(final Iterable<ConsumerRecord<byte[], byte[]>> rawRecords)
For every Kafka ConsumerRecord in the input rawRecords
, addRawRecords
does the following:
-
Requests the RecordDeserializer to deserialize the record (with the ProcessorContext)
-
FIXME
-
Creates a StampedRecord for the record and the record timestamp
-
Inserts the
StampedRecord
at the end of the fifoQueue -
FIXME
While processing ConsumerRecords
, addRawRecords
prints out the following TRACE message to the logs:
Source node [name] extracted timestamp [timestamp] for record [record]
With all ConsumerRecords
processed, addRawRecords
…FIXME
In the end, addRawRecords
returns the number of ConsumerRecords in the queue.
Note
|
|
Note
|
addRawRecords is used exclusively when PartitionGroup is requested to add records to a RecordQueue for a Kafka partition.
|
Clearing (Resetting) RecordQueue — clear
Method
void clear()
clear
…FIXME
In the end, clear
(re)sets the partitionTime to NOT_KNOWN
.
Note
|
clear is used exclusively when PartitionGroup is requested to clear.
|
Requesting Number of Records in Queue — size
Method
int size()
size
simply returns the number of records in the fifoQueue.
Note
|
|
Internal Properties
Name | Description |
---|---|
|
Java’s java.util.ArrayDeque of StampedRecords (i.e. orderable Kafka Used when…FIXME |
|
|
|
RecordDeserializer (for the SourceNode and DeserializationExceptionHandler) Used when…FIXME |