Class RemovedPartitionState<K,V>
PartitionState used for when partition assignments are removed, to avoid managing null
references or Optionals. By replacing with a no op implementation, we protect for stale messages still in
queues which reference it, among other things.
The alternative to this implementation, is having PartitionStateManager.getPartitionState(TopicPartition)
return Optional, which forces the implicit null check everywhere partition state is retrieved. This was
drafted to a degree, but found to be extremely invasive, where this solution with decent separation of concerns and
encapsulation, is sufficient and potentially more useful as is non-destructive. Potential issue is that of memory
leak as the collection will forever expand. However, even massive partition counts to a single consumer would be in
the hundreds of thousands, this would only result in hundreds of thousands of TopicPartition object keys all
pointing to the same instance of RemovedPartitionState.
-
Field Summary
FieldsFields inherited from class io.confluent.parallelconsumer.state.PartitionState
KAFKA_OFFSET_ABSENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWorkContainer(WorkContainer<K, V> wc) intlongThe highest seen offset for a partition.longHighest offset which has completed successfully ("succeeded").static PartitionStateorg.apache.kafka.common.TopicPartitiongetTp()booleanbooleanisRecordPreviouslyCompleted(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> rec) booleanHas this partition been removed? No.voidonSuccess(WorkContainer<K, V> work) Methods inherited from class io.confluent.parallelconsumer.state.PartitionState
getAllIncompleteOffsets, getCommitDataIfDirty, getOffsetHighestSequentialSucceeded, isBlocked, onFailure, onOffsetCommitSuccess, onPartitionsRemoved, toString
-
Field Details
-
NO_OP
- See Also:
-
-
Constructor Details
-
RemovedPartitionState
public RemovedPartitionState()
-
-
Method Details
-
getSingleton
-
isRemoved
public boolean isRemoved()Description copied from class:PartitionStateHas this partition been removed? No.- Overrides:
isRemovedin classPartitionState<K,V> - Returns:
- by definition false in this implementation
-
getTp
public org.apache.kafka.common.TopicPartition getTp()- Overrides:
getTpin classPartitionState<K,V>
-
addWorkContainer
- Overrides:
addWorkContainerin classPartitionState<K,V>
-
getIncompleteOffsetsBelowHighestSucceeded
- Overrides:
getIncompleteOffsetsBelowHighestSucceededin classPartitionState<K,V> - Returns:
- incomplete offsets which are lower than the highest succeeded
-
getOffsetHighestSeen
public long getOffsetHighestSeen()Description copied from class:PartitionStateThe highest seen offset for a partition.Starts off as -1 - no data. Offsets in Kafka are never negative, so this is fine.
- Overrides:
getOffsetHighestSeenin classPartitionState<K,V>
-
getOffsetHighestSucceeded
public long getOffsetHighestSucceeded()Description copied from class:PartitionStateHighest offset which has completed successfully ("succeeded").Note that this may in some conditions, there may be a gap between this and the next offset to poll - that being, there may be some number of transaction marker records above it, and the next offset to poll.
- Overrides:
getOffsetHighestSucceededin classPartitionState<K,V>
-
isRecordPreviouslyCompleted
public boolean isRecordPreviouslyCompleted(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> rec) - Overrides:
isRecordPreviouslyCompletedin classPartitionState<K,V>
-
hasWorkInCommitQueue
public boolean hasWorkInCommitQueue()- Overrides:
hasWorkInCommitQueuein classPartitionState<K,V>
-
getCommitQueueSize
public int getCommitQueueSize()- Overrides:
getCommitQueueSizein classPartitionState<K,V>
-
onSuccess
- Overrides:
onSuccessin classPartitionState<K,V>
-