Class RemovedPartitionState<K,V>
public class RemovedPartitionState<K,V> extends PartitionState<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
-
Constructor Summary
Constructors Constructor Description RemovedPartitionState() -
Method Summary
Modifier and Type Method Description voidaddWorkContainer(WorkContainer<K,V> wc)intgetCommitQueueSize()Set<Long>getIncompleteOffsetsBelowHighestSucceeded()longgetOffsetHighestSeen()The highest seen offset for a partition.longgetOffsetHighestSucceeded()Highest offset which has completed successfully ("succeeded").static PartitionStategetSingleton()org.apache.kafka.common.TopicPartitiongetTp()booleanhasWorkInCommitQueue()booleanisRecordPreviouslyCompleted(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> rec)booleanisRemoved()Has 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:
- Constant Field Values
-
-
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").- 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>
-