pub struct ConsumerLogTruncationError { /* private fields */ }Expand description
Log truncation was detected: the broker’s log diverges from the offsets the consumer had fetched.
Corresponds to Java’s LogTruncationException. It has no entry in Errors,
so it carries no protocol code.
Java extends chain:
LogTruncationException -> OffsetOutOfRangeException ->
InvalidOffsetException -> KafkaException
The OffsetOutOfRangeException in that chain is the consumer package’s, so
this is a
ConsumerOffsetOutOfRangeError too —
which is why it carries the same offset_out_of_range_partitions map.
Implementations§
Source§impl ConsumerLogTruncationError
impl ConsumerLogTruncationError
Sourcepub fn new(
offset_out_of_range_partitions: HashMap<TopicPartition, i64>,
divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Self
pub fn new( offset_out_of_range_partitions: HashMap<TopicPartition, i64>, divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Self
Mirrors Java’s
LogTruncationException(Map<TopicPartition, Long>, Map<TopicPartition, OffsetAndMetadata>),
which composes the message from the divergent offsets:
"Truncated partitions detected with divergent offsets " + divergentOffsets.
Sourcepub fn with_message(
message: impl Into<String>,
offset_out_of_range_partitions: HashMap<TopicPartition, i64>,
divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Self
pub fn with_message( message: impl Into<String>, offset_out_of_range_partitions: HashMap<TopicPartition, i64>, divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Self
Mirrors Java’s three-argument
LogTruncationException(String, Map<TopicPartition, Long>, Map<TopicPartition, OffsetAndMetadata>).
Sourcepub fn offset_out_of_range_partitions(&self) -> &HashMap<TopicPartition, i64>
pub fn offset_out_of_range_partitions(&self) -> &HashMap<TopicPartition, i64>
The out-of-range offset per partition.
Sourcepub fn divergent_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
pub fn divergent_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
The divergent offset per partition.
Sourcepub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
pub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
The partitions this error covers.
LogTruncationException does not override
OffsetOutOfRangeException.partitions()
(OffsetOutOfRangeException.java:51-54), so this is the key set of
offset_out_of_range_partitions — NOT of
divergent_offsets. The distinction is the
whole point of the accessor: Java’s javadoc
(LogTruncationException.java:48-56) tells the caller to iterate
partitions() and then look each one up in divergentOffsets(),
“because there is no guarantee that this offset will be known” for
every truncated partition.
Returns an iterator rather than a HashSet for the same reason as
ConsumerOffsetOutOfRangeError::partitions:
Java’s keySet() is a view, not a copy.
Trait Implementations§
Source§impl Clone for ConsumerLogTruncationError
impl Clone for ConsumerLogTruncationError
Source§fn clone(&self) -> ConsumerLogTruncationError
fn clone(&self) -> ConsumerLogTruncationError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more