KAFKA-12829: Remove deprecated Topology#addProcessor of old Processor API#18154
KAFKA-12829: Remove deprecated Topology#addProcessor of old Processor API#18154mjsax merged 2 commits intoapache:trunkfrom
Conversation
| import org.apache.kafka.test.MockApiProcessor; | ||
| import org.apache.kafka.test.MockApiProcessorSupplier; | ||
| import org.apache.kafka.test.MockInternalNewProcessorContext; | ||
| import org.apache.kafka.test.MockInternalProcessorContext; |
There was a problem hiding this comment.
Follow up clean from #18103
Rename this class, what result in lot of updates in many files...
|
|
||
|
|
||
| public class KStreamNewProcessorApiTest { | ||
| public class KStreamProcessorApiTest { |
There was a problem hiding this comment.
This is a similar update -- we don't have the old Processor API any longer, so dropping the New from this name, too.
| props.setProperty(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | ||
| props.setProperty(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | ||
| props.setProperty(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class.getName()); | ||
| props.setProperty(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class.getName()); |
There was a problem hiding this comment.
Side cleanup to get rid of some IntelliJ warning. (also cleaner code.
Similar stuff below.
| assertEquals("value2", store.get("key2")); | ||
| assertEquals("value3", store.get("key3")); | ||
| assertNull(store.get("key4")); | ||
| } |
There was a problem hiding this comment.
Diff is just weird.. this was not removed
|
|
||
| @Deprecated // testing old PAPI | ||
| @Test | ||
| public void testDrivingConnectedStateStoreInDifferentProcessorsTopologyWithOldAPI() { |
There was a problem hiding this comment.
removed this (and some other tests) -- verified that we have equivalent tests for new Processor API for all of them
| assertEquals("key3", results.get(2).key); | ||
| assertEquals("value3", results.get(2).value); | ||
|
|
||
| } |
| .addSink("sink", OUTPUT_TOPIC_1, new DroppingPartitioner(), "processor"); | ||
| } | ||
|
|
||
| @Deprecated // testing old PAPI |
There was a problem hiding this comment.
This annotation was wrong -- should have been @SuppressWarning("deprecation")
Updating this code to use new Processor API now.
| .addSink("counts", OUTPUT_TOPIC_1, "processor"); | ||
| } | ||
|
|
||
| @Deprecated // testing old PAPI |
| * A processor that stores each key-value pair in an in-memory key-value store registered with the context. | ||
| */ | ||
| @SuppressWarnings("deprecation") // Old PAPI. Needs to be migrated. | ||
| protected static class OldAPIStatefulProcessor extends org.apache.kafka.streams.processor.AbstractProcessor<String, String> { |
There was a problem hiding this comment.
There is already a StatefulProcessor for the new PAPI -- nothing to be migrated -- deleting.
| } | ||
|
|
||
| @SuppressWarnings("deprecation") // Old PAPI. Needs to be migrated. | ||
| private <K, V> org.apache.kafka.streams.processor.ProcessorSupplier<K, V> define(final org.apache.kafka.streams.processor.Processor<K, V> processor) { |
There was a problem hiding this comment.
just dropped this one -- not really useful to have..
| } | ||
|
|
||
| @SuppressWarnings("deprecation") // Old PAPI. Needs to be migrated. | ||
| private <K, V> org.apache.kafka.streams.processor.ProcessorSupplier<K, V> defineWithStoresOldAPI(final Supplier<org.apache.kafka.streams.processor.Processor<K, V>> supplier, |
There was a problem hiding this comment.
There is already defineWithStores() for new PAPI -- nothing to be migrated -- deleting
| private <KIn, VIn, KOut, VOut> ProcessorSupplier<KIn, VIn, KOut, VOut> defineWithStores(final Supplier<Processor<KIn, VIn, KOut, VOut>> supplier, | ||
| final Set<StoreBuilder<?>> stores) { | ||
| return new ProcessorSupplier<KIn, VIn, KOut, VOut>() { | ||
| return new ProcessorSupplier<>() { |
| return topology | ||
| .addSource("source", STRING_DESERIALIZER, STRING_DESERIALIZER, INPUT_TOPIC_1) | ||
| .addProcessor("processor", define(new OldAPIStatefulProcessor(storeName)), "source") | ||
| .addProcessor("processor", () -> new StatefulProcessor(storeName), "source") |
There was a problem hiding this comment.
Indeed, it looks like OldAPIStatefulProcessor has been corrected to StatefulProcessor for migrating to current API. Got it! Thanks for teaching!
|
@mjsax could you please fix the conflicts ? |
0b3c223 to
e63d9a3
Compare
| import static org.mockito.Mockito.when; | ||
|
|
||
| @SuppressWarnings("deprecation") // this is a test of a deprecated API | ||
| public class MockProcessorContextTest { |
There was a problem hiding this comment.
The deprecated org.apache.kafka.streams.processor.MockProcessorContext still exists in the codebase. Should we retain the unit tests?
There was a problem hiding this comment.
Good question. I suppose the trouble is that the unit test uses the removed classes, but the unit under test will not be removed yet. Can the tests be rewritten with transformers?
lucasbru
left a comment
There was a problem hiding this comment.
Yes, LGTM modulo the question raised by Chia
|
Java 23: Java 17: |
… API (#18154) Reviewers: John Huang <pegasashjy@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>, Bill Bejeck <bill@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
|
Merged to |
…e-old-protocol-versions * apache-github/trunk: KAFKA-18312: Added entityType: topicName to SubscribedTopicNames in ShareGroupHeartbeatRequest.json (apache#18285) HOTFIX: fix incompatible types: Optional<TimestampAndOffset> cannot be converted to Option<TimestampAndOffset> (apache#18284) MINOR Fix some test-catalog issues (apache#18272) KAFKA-18180: Move OffsetResultHolder to storage module (apache#18100) KAFKA-18301; Make coordinator records first class citizen (apache#18261) KAFKA-18262 Remove DefaultPartitioner and UniformStickyPartitioner (apache#18204) KAFKA-18296 Remove deprecated KafkaBasedLog constructor (apache#18257) KAFKA-12829: Remove old Processor and ProcessorSupplier interfaces (apache#18238) KAFKA-18292 Remove deprecated methods of UpdateFeaturesOptions (apache#18245) KAFKA-12829: Remove deprecated Topology#addProcessor of old Processor API (apache#18154) KAFKA-18035, KAFKA-18306, KAFKA-18092: Address TransactionsTest flaky tests (apache#18264) MINOR: change the default linger time in the new coordinator (apache#18274) KAFKA-18305: validate controller.listener.names is not in inter.broker.listener.name for kcontrollers (apache#18222) KAFKA-18207: Serde for handling transaction records (apache#18136) KAFKA-13722: Refactor Kafka Streams store interfaces (apache#18243) KAFKA-17131: Refactor TimeDefinitions (apache#18241) MINOR: Fix MessageFormatters (apache#18266) Mark flaky tests for Dec 18, 2024 (apache#18263)
… API (apache#18154) Reviewers: John Huang <pegasashjy@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>, Bill Bejeck <bill@confluent.io>, Lucas Brutschy <lbrutschy@confluent.io>
Must be cherry-picked to
4.0branch.