public class CustomTimestampPolicyWithLimitedDelay<K,V> extends TimestampPolicy<K,V>
Min(now(), Max(event timestamp so far)) - max delay)'.
However, watermark is never set in future and capped to 'now - max delay'. In addition, watermark
advanced to 'now - max delay' when a partition is idle.TimestampPolicy.PartitionContext| Constructor and Description |
|---|
CustomTimestampPolicyWithLimitedDelay(SerializableFunction<KafkaRecord<K,V>,Instant> timestampFunction,
Duration maxDelay,
java.util.Optional<Instant> previousWatermark)
A policy for custom record timestamps where timestamps are expected to be roughly monotonically
increasing with out of order event delays less than
maxDelay. |
| Modifier and Type | Method and Description |
|---|---|
Instant |
getTimestampForRecord(TimestampPolicy.PartitionContext ctx,
KafkaRecord<K,V> record)
Returns record timestamp (aka event time).
|
Instant |
getWatermark(TimestampPolicy.PartitionContext ctx)
Returns watermark for the partition.
|
public CustomTimestampPolicyWithLimitedDelay(SerializableFunction<KafkaRecord<K,V>,Instant> timestampFunction, Duration maxDelay, java.util.Optional<Instant> previousWatermark)
maxDelay. The watermark at any time
is Min(now(), max_event_timestamp) - maxDelay.timestampFunction - A function to extract timestamp from the recordmaxDelay - For any record in the Kafka partition, the timestamp of any subsequent record
is expected to be after current record timestamp - maxDelay.previousWatermark - Latest check-pointed watermark, see TimestampPolicyFactory.createTimestampPolicy(TopicPartition, Optional)public Instant getTimestampForRecord(TimestampPolicy.PartitionContext ctx, KafkaRecord<K,V> record)
TimestampPolicygetTimestampForRecord in class TimestampPolicy<K,V>public Instant getWatermark(TimestampPolicy.PartitionContext ctx)
TimestampPolicyUnboundedSource.UnboundedReader#getWatermark() for more guidance on watermarks. E.g. if the
record timestamp is 'LogAppendTime', watermark would be the timestamp of the last record since
'LogAppendTime' monotonically increases within a partition.getWatermark in class TimestampPolicy<K,V>