You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ableegoldman (via GitHub)" <gi...@apache.org> on 2024/12/29 01:02:55 UTC
[PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
ableegoldman opened a new pull request, #18342:
URL: https://github.com/apache/kafka/pull/18342
Minor followup to https://github.com/apache/kafka/pull/18195 that I split out into a separate PR since that one was getting a bit long. Should be rebased & reviewed after that one is merged.
Introduces a new class for windowed graph nodes with a grace period defined to improve (slightly) the type safety
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1917450316
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/GraphGraceSearchUtil.java:
##########
@@ -70,27 +61,4 @@ private static long findAndVerifyWindowGrace(final GraphNode graphNode, final St
return inheritedGrace;
}
- @SuppressWarnings("rawtypes")
- private static Long extractGracePeriod(final GraphNode node) {
Review Comment:
haha yeah it's a step in the right direction...but it's still only just one step 😛
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1917416613
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/GroupedStreamAggregateBuilder.java:
##########
@@ -66,23 +66,67 @@ class GroupedStreamAggregateBuilder<K, V> {
this.userProvidedRepartitionTopicName = groupedInternal.name();
}
- <KR, VR> KTable<KR, VR> build(final NamedInternal functionName,
- final StoreFactory storeFactory,
- final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
- final String queryableStoreName,
- final Serde<KR> keySerde,
- final Serde<VR> valueSerde,
- final boolean isOutputVersioned) {
- assert queryableStoreName == null || queryableStoreName.equals(storeFactory.storeName());
+ <KR, VR> KTable<KR, VR> buildNonWindowed(final NamedInternal functionName,
+ final String storeName,
+ final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
+ final String queryableStoreName,
+ final Serde<KR> keySerde,
+ final Serde<VR> valueSerde,
+ final boolean isOutputVersioned) {
+ final String aggFunctionName = functionName.name();
+
+ final ProcessorGraphNode<K, V> aggProcessorNode =
+ new ProcessorGraphNode<>(
+ aggFunctionName,
+ new ProcessorParameters<>(aggregateSupplier, aggFunctionName)
+ );
+ aggProcessorNode.setOutputVersioned(isOutputVersioned);
+
+ return build(aggFunctionName, storeName, aggregateSupplier, aggProcessorNode, queryableStoreName, keySerde, valueSerde);
+ }
+
+ <KR, VR> KTable<KR, VR> buildWindowed(final NamedInternal functionName,
+ final String storeName,
+ final long gracePeriod,
+ final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
+ final String queryableStoreName,
+ final Serde<KR> keySerde,
+ final Serde<VR> valueSerde,
+ final boolean isOutputVersioned) {
final String aggFunctionName = functionName.name();
+ final GracePeriodGraphNode<K, V> gracePeriodAggProcessorNode =
+ new GracePeriodGraphNode<>(
+ aggFunctionName,
+ new ProcessorParameters<>(aggregateSupplier, aggFunctionName),
+ gracePeriod
+ );
+
+ gracePeriodAggProcessorNode.setOutputVersioned(isOutputVersioned);
+
+ return build(aggFunctionName, storeName, aggregateSupplier, gracePeriodAggProcessorNode, queryableStoreName, keySerde, valueSerde);
+ }
+
+ <KR, VR> KTable<KR, VR> build(final String aggFunctionName,
+ final String storeName,
Review Comment:
whoops 🙂
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman merged PR #18342:
URL: https://github.com/apache/kafka/pull/18342
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1915899685
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/GraphGraceSearchUtil.java:
##########
@@ -70,27 +61,4 @@ private static long findAndVerifyWindowGrace(final GraphNode graphNode, final St
return inheritedGrace;
}
- @SuppressWarnings("rawtypes")
- private static Long extractGracePeriod(final GraphNode node) {
Review Comment:
Still a good progress that we replaced four nested instanceof with just one :) Just kidding.
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/GroupedStreamAggregateBuilder.java:
##########
@@ -66,23 +66,67 @@ class GroupedStreamAggregateBuilder<K, V> {
this.userProvidedRepartitionTopicName = groupedInternal.name();
}
- <KR, VR> KTable<KR, VR> build(final NamedInternal functionName,
- final StoreFactory storeFactory,
- final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
- final String queryableStoreName,
- final Serde<KR> keySerde,
- final Serde<VR> valueSerde,
- final boolean isOutputVersioned) {
- assert queryableStoreName == null || queryableStoreName.equals(storeFactory.storeName());
+ <KR, VR> KTable<KR, VR> buildNonWindowed(final NamedInternal functionName,
+ final String storeName,
+ final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
+ final String queryableStoreName,
+ final Serde<KR> keySerde,
+ final Serde<VR> valueSerde,
+ final boolean isOutputVersioned) {
+ final String aggFunctionName = functionName.name();
+
+ final ProcessorGraphNode<K, V> aggProcessorNode =
+ new ProcessorGraphNode<>(
+ aggFunctionName,
+ new ProcessorParameters<>(aggregateSupplier, aggFunctionName)
+ );
+ aggProcessorNode.setOutputVersioned(isOutputVersioned);
+
+ return build(aggFunctionName, storeName, aggregateSupplier, aggProcessorNode, queryableStoreName, keySerde, valueSerde);
+ }
+
+ <KR, VR> KTable<KR, VR> buildWindowed(final NamedInternal functionName,
+ final String storeName,
+ final long gracePeriod,
+ final KStreamAggProcessorSupplier<K, V, KR, VR> aggregateSupplier,
+ final String queryableStoreName,
+ final Serde<KR> keySerde,
+ final Serde<VR> valueSerde,
+ final boolean isOutputVersioned) {
final String aggFunctionName = functionName.name();
+ final GracePeriodGraphNode<K, V> gracePeriodAggProcessorNode =
+ new GracePeriodGraphNode<>(
+ aggFunctionName,
+ new ProcessorParameters<>(aggregateSupplier, aggFunctionName),
+ gracePeriod
+ );
+
+ gracePeriodAggProcessorNode.setOutputVersioned(isOutputVersioned);
+
+ return build(aggFunctionName, storeName, aggregateSupplier, gracePeriodAggProcessorNode, queryableStoreName, keySerde, valueSerde);
+ }
+
+ <KR, VR> KTable<KR, VR> build(final String aggFunctionName,
+ final String storeName,
Review Comment:
nit: misaligned indentation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1915851802
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/GracePeriodGraphNode.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.streams.kstream.internals.graph;
+
+/**
+ * Represents a stateful {@link ProcessorGraphNode} where a semantic grace period is defined for the processor
+ * and its state.
+ */
+public class GracePeriodGraphNode<K, V> extends ProcessorGraphNode<K, V> {
Review Comment:
I wonder if it makes sense to add something directly to `ProcessorGraphNode` such as `ProcessorGraphNode#getWindowInformation` that returns an `Optional<WindowInformation>` that contains grace period.
That removes the `instanceof GracePeriodGraphNode` check, at the cost of adding something empty to all the other nodes. I'm ambivalent as either approach works for me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1915845539
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/GraphGraceSearchUtil.java:
##########
@@ -70,27 +61,4 @@ private static long findAndVerifyWindowGrace(final GraphNode graphNode, final St
return inheritedGrace;
}
- @SuppressWarnings("rawtypes")
- private static Long extractGracePeriod(final GraphNode node) {
Review Comment:
Main point of this PR is to get rid of this ugly thing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18026: KIP-1112, clean up graph node grace period resolution [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #18342:
URL: https://github.com/apache/kafka/pull/18342#discussion_r1915858876
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/GracePeriodGraphNode.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.streams.kstream.internals.graph;
+
+/**
+ * Represents a stateful {@link ProcessorGraphNode} where a semantic grace period is defined for the processor
+ * and its state.
+ */
+public class GracePeriodGraphNode<K, V> extends ProcessorGraphNode<K, V> {
Review Comment:
yeah I considered that too. In the end I opted for the smaller change, as there are some other things that work similarly which would be nice to clean up, so I was thinking it might make sense to wait until everything is done and then we can consider the full picture
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org