/** * Record emission, if a timestamp will be attached from an assigner that is * also a punctuated watermark generator. */ private void emitRecordWithTimestampAndPunctuatedWatermark( T record, KafkaTopicPartitionState<KPH> partitionState, long offset, long kafkaEventTimestamp) { @SuppressWarnings("unchecked") final KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH> withWatermarksState = (KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH>) partitionState; // only one thread ever works on accessing timestamps and watermarks // from the punctuated extractor final long timestamp = withWatermarksState.getTimestampForRecord(record, kafkaEventTimestamp); final Watermark newWatermark = withWatermarksState.checkAndGetNewWatermark(record, timestamp); // emit the record with timestamp, using the usual checkpoint lock to guarantee // atomicity of record emission and offset state update synchronized (checkpointLock) { sourceContext.collectWithTimestamp(record, timestamp); partitionState.setOffset(offset); } // if we also have a new per-partition watermark, check if that is also a // new cross-partition watermark if (newWatermark != null) { updateMinPunctuatedWatermark(newWatermark); } }
/** * Record emission, if a timestamp will be attached from an assigner that is * also a punctuated watermark generator. */ private void emitRecordWithTimestampAndPunctuatedWatermark( T record, KafkaTopicPartitionState<KPH> partitionState, long offset, long kafkaEventTimestamp) { @SuppressWarnings("unchecked") final KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH> withWatermarksState = (KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH>) partitionState; // only one thread ever works on accessing timestamps and watermarks // from the punctuated extractor final long timestamp = withWatermarksState.getTimestampForRecord(record, kafkaEventTimestamp); final Watermark newWatermark = withWatermarksState.checkAndGetNewWatermark(record, timestamp); // emit the record with timestamp, using the usual checkpoint lock to guarantee // atomicity of record emission and offset state update synchronized (checkpointLock) { sourceContext.collectWithTimestamp(record, timestamp); partitionState.setOffset(offset); } // if we also have a new per-partition watermark, check if that is also a // new cross-partition watermark if (newWatermark != null) { updateMinPunctuatedWatermark(newWatermark); } }
/** * Record emission, if a timestamp will be attached from an assigner that is * also a punctuated watermark generator. */ protected void emitRecordWithTimestampAndPunctuatedWatermark( T record, KafkaTopicPartitionState<KPH> partitionState, long offset, long kafkaEventTimestamp) { @SuppressWarnings("unchecked") final KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH> withWatermarksState = (KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH>) partitionState; // only one thread ever works on accessing timestamps and watermarks // from the punctuated extractor final long timestamp = withWatermarksState.getTimestampForRecord(record, kafkaEventTimestamp); final Watermark newWatermark = withWatermarksState.checkAndGetNewWatermark(record, timestamp); // emit the record with timestamp, using the usual checkpoint lock to guarantee // atomicity of record emission and offset state update synchronized (checkpointLock) { sourceContext.collectWithTimestamp(record, timestamp); partitionState.setOffset(offset); } // if we also have a new per-partition watermark, check if that is also a // new cross-partition watermark if (newWatermark != null) { updateMinPunctuatedWatermark(newWatermark); } }
/** * Record emission, if a timestamp will be attached from an assigner that is * also a punctuated watermark generator. */ private void emitRecordWithTimestampAndPunctuatedWatermark( T record, KafkaTopicPartitionState<KPH> partitionState, long offset, long kafkaEventTimestamp) { @SuppressWarnings("unchecked") final KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH> withWatermarksState = (KafkaTopicPartitionStateWithPunctuatedWatermarks<T, KPH>) partitionState; // only one thread ever works on accessing timestamps and watermarks // from the punctuated extractor final long timestamp = withWatermarksState.getTimestampForRecord(record, kafkaEventTimestamp); final Watermark newWatermark = withWatermarksState.checkAndGetNewWatermark(record, timestamp); // emit the record with timestamp, using the usual checkpoint lock to guarantee // atomicity of record emission and offset state update synchronized (checkpointLock) { sourceContext.collectWithTimestamp(record, timestamp); partitionState.setOffset(offset); } // if we also have a new per-partition watermark, check if that is also a // new cross-partition watermark if (newWatermark != null) { updateMinPunctuatedWatermark(newWatermark); } }