You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ab...@apache.org on 2022/02/26 03:12:47 UTC
[kafka] branch trunk updated: KAFKA-13281: allow #removeNamedTopology while in the CREATED state (#11810)
This is an automated email from the ASF dual-hosted git repository.
ableegoldman pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new abb74d4 KAFKA-13281: allow #removeNamedTopology while in the CREATED state (#11810)
abb74d4 is described below
commit abb74d406a13bd989e718f737b18073af5a626d5
Author: Walker Carlson <18...@users.noreply.github.com>
AuthorDate: Fri Feb 25 21:11:06 2022 -0600
KAFKA-13281: allow #removeNamedTopology while in the CREATED state (#11810)
We should be able to change the topologies while still in the CREATED state. We already allow adding them, but this should include removing them as well
Reviewers: Anna Sophie Blee-Goldman <ab...@apache.org>
---
.../internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java | 2 +-
.../kafka/streams/integration/NamedTopologyIntegrationTest.java | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java b/streams/src/main/java/org/apache/kafka/streams/processor/internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java
index a0ccedb..fb005d1 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/namedtopology/KafkaStreamsNamedTopologyWrapper.java
@@ -203,7 +203,7 @@ public class KafkaStreamsNamedTopologyWrapper extends KafkaStreams {
final KafkaFutureImpl<Void> removeTopologyFuture = new KafkaFutureImpl<>();
- if (!isRunningOrRebalancing()) {
+ if (hasStartedOrFinishedShuttingDown()) {
log.error("Attempted to remove topology {} from while the Kafka Streams was in state {}, "
+ "application must be started first.", topologyToRemove, state
);
diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java b/streams/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java
index 73b4085..5db1585 100644
--- a/streams/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/integration/NamedTopologyIntegrationTest.java
@@ -340,7 +340,7 @@ public class NamedTopologyIntegrationTest {
}
@Test
- public void shouldAddNamedTopologiesBeforeStartingAndRouteQueriesToCorrectTopology() throws Exception {
+ public void shouldAddAndRemoveNamedTopologiesBeforeStartingAndRouteQueriesToCorrectTopology() throws Exception {
try {
// for this test we have one of the topologies read from an input topic with just one partition so
// that there's only one instance of that topology's store and thus should always have exactly one
@@ -355,6 +355,9 @@ public class NamedTopologyIntegrationTest {
topology1Builder.stream(INPUT_STREAM_1).groupBy((k, v) -> k).count(Materialized.as(topology1Store)).toStream().to(OUTPUT_STREAM_1);
topology2Builder.stream(SINGLE_PARTITION_INPUT_STREAM).groupByKey().count(Materialized.as(topology2Store)).toStream().to(SINGLE_PARTITION_OUTPUT_STREAM);
streams.addNamedTopology(topology1Builder.build());
+ streams.removeNamedTopology(TOPOLOGY_1);
+ assertThat(streams.getTopologyByName(TOPOLOGY_1), is(Optional.empty()));
+ streams.addNamedTopology(topology1Builder.build());
streams.addNamedTopology(topology2Builder.build());
IntegrationTestUtils.startApplicationAndWaitUntilRunning(singletonList(streams), Duration.ofSeconds(15));