-
Notifications
You must be signed in to change notification settings - Fork 14.6k
KAFKA-12829: Remove deprecated Topology#addProcessor of old Processor API #18154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-12829: Remove deprecated Topology#addProcessor of old Processor API #18154
Conversation
@@ -57,7 +57,7 @@ | |||
import org.apache.kafka.test.GenericInMemoryKeyValueStore; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up clean from #18103
Rename this class, what result in lot of updates in many files...
@@ -46,7 +46,7 @@ | |||
import static java.util.Arrays.asList; | |||
|
|||
|
|||
public class KStreamNewProcessorApiTest { | |||
public class KStreamProcessorApiTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff is just weird.. this was not removed
|
||
@Deprecated // testing old PAPI | ||
@Test | ||
public void testDrivingConnectedStateStoreInDifferentProcessorsTopologyWithOldAPI() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird diff..
@@ -1568,21 +1105,19 @@ private Topology createSimpleTopologyWithDroppingPartitioner() { | |||
.addSink("sink", OUTPUT_TOPIC_1, new DroppingPartitioner(), "processor"); | |||
} | |||
|
|||
@Deprecated // testing old PAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This annotation was wrong -- should have been @SuppressWarning("deprecation")
Updating this code to use new Processor API now.
.addStateStore(Stores.keyValueStoreBuilder(Stores.inMemoryKeyValueStore(storeName), Serdes.String(), Serdes.String()), "processor") | ||
.addSink("counts", OUTPUT_TOPIC_1, "processor"); | ||
} | ||
|
||
@Deprecated // testing old PAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a StatefulProcessor
for the new PAPI -- nothing to be migrated -- deleting.
@@ -1775,30 +1286,9 @@ public void process(final Record<String, String> record) { | |||
} | |||
} | |||
|
|||
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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<>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side cleanup
private Topology createStatefulTopology(final String storeName) { | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjsax thanks for this patch. LGTM and one small question is left.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @mjsax - LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, LGTM modulo the question raised by Chia
Java 23:
Java 17:
|
… API (#18154) Reviewers: John Huang <[email protected]>, Chia-Ping Tsai <[email protected]>, Bill Bejeck <[email protected]>, Lucas Brutschy <[email protected]>
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 <[email protected]>, Chia-Ping Tsai <[email protected]>, Bill Bejeck <[email protected]>, Lucas Brutschy <[email protected]>
Must be cherry-picked to
4.0
branch.