diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsProducer.java b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsProducer.java index b77356557639e..1048b5a2ecfdf 100644 --- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsProducer.java +++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsProducer.java @@ -239,7 +239,7 @@ private static boolean isRecoverable(final KafkaException uncaughtException) { * @throws IllegalStateException if EOS is disabled * @throws TaskMigratedException */ - protected void commitTransaction(final Map offsets, + public void commitTransaction(final Map offsets, final ConsumerGroupMetadata consumerGroupMetadata) { if (!eosEnabled()) { throw new IllegalStateException(formatException("Exactly-once is not enabled")); diff --git a/streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java b/streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java index 0864880579255..665e5e01fb4d6 100644 --- a/streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java +++ b/streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java @@ -29,7 +29,6 @@ import org.apache.kafka.common.MetricName; import org.apache.kafka.common.PartitionInfo; import org.apache.kafka.common.TopicPartition; -import org.apache.kafka.common.errors.ProducerFencedException; import org.apache.kafka.common.header.Headers; import org.apache.kafka.common.metrics.MetricConfig; import org.apache.kafka.common.metrics.Metrics; @@ -44,7 +43,6 @@ import org.apache.kafka.streams.errors.LogAndContinueExceptionHandler; import org.apache.kafka.streams.errors.TopologyException; import org.apache.kafka.streams.internals.StreamsConfigUtils; -import org.apache.kafka.streams.internals.StreamsConfigUtils.ProcessingMode; import org.apache.kafka.streams.kstream.Windowed; import org.apache.kafka.streams.processor.ProcessorContext; import org.apache.kafka.streams.processor.PunctuationType; @@ -233,7 +231,7 @@ public class TopologyTestDriver implements Closeable { private final MockConsumer consumer; private final MockProducer producer; - private final TestDriverProducer testDriverProducer; + private final StreamsProducer testDriverProducer; private final Map partitionsByInputTopic = new HashMap<>(); private final Map globalPartitionsByInputTopic = new HashMap<>(); @@ -345,7 +343,8 @@ public List partitionsFor(final String topic) { return Collections.singletonList(new PartitionInfo(topic, PARTITION_ID, null, null, null)); } }; - testDriverProducer = new TestDriverProducer( + + testDriverProducer = new StreamsProducer( producer, StreamsConfigUtils.processingMode(streamsConfig), mockWallClockTime, @@ -738,7 +737,14 @@ private Queue> getRecordsQueue(final String topic public final TestInputTopic createInputTopic(final String topicName, final Serializer keySerializer, final Serializer valueSerializer) { - return new TestInputTopic<>(this, topicName, keySerializer, valueSerializer, Instant.now(), Duration.ZERO); + return new TestInputTopic<>( + this, + topicName, + keySerializer, + valueSerializer, + Instant.ofEpochMilli(mockWallClockTime.milliseconds()), + Duration.ZERO + ); } /** @@ -985,7 +991,7 @@ private void throwIfBuiltInStore(final StateStore stateStore) { public KeyValueStore getKeyValueStore(final String name) { final StateStore store = getStateStore(name, false); if (store instanceof TimestampedKeyValueStore) { - log.info("Method #getTimestampedKeyValueStore() should be used to access a TimestampedKeyValueStore."); + log.warn("Method #getTimestampedKeyValueStore() should be used to access a TimestampedKeyValueStore."); return new KeyValueStoreFacade<>((TimestampedKeyValueStore) store); } return store instanceof KeyValueStore ? (KeyValueStore) store : null; @@ -1063,7 +1069,7 @@ public VersionedKeyValueStore getVersionedKeyValueStore(final Strin public WindowStore getWindowStore(final String name) { final StateStore store = getStateStore(name, false); if (store instanceof TimestampedWindowStore) { - log.info("Method #getTimestampedWindowStore() should be used to access a TimestampedWindowStore."); + log.warn("Method #getTimestampedWindowStore() should be used to access a TimestampedWindowStore."); return new WindowStoreFacade<>((TimestampedWindowStore) store); } return store instanceof WindowStore ? (WindowStore) store : null; @@ -1351,19 +1357,4 @@ public Position getPosition() { } } - private static class TestDriverProducer extends StreamsProducer { - - public TestDriverProducer(final Producer producer, - final ProcessingMode processingMode, - final Time time, - final LogContext logContext) { - super(producer, processingMode, time, logContext); - } - - @Override - public void commitTransaction(final Map offsets, - final ConsumerGroupMetadata consumerGroupMetadata) throws ProducerFencedException { - super.commitTransaction(offsets, consumerGroupMetadata); - } - } }