You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "agavra (via GitHub)" <gi...@apache.org> on 2023/10/26 23:43:04 UTC
[PR] [KIP-954] support custom DSL store providers [kafka]
agavra opened a new pull request, #14648:
URL: https://github.com/apache/kafka/pull/14648
### Overview
Implementation for [KIP-954](https://cwiki.apache.org/confluence/display/KAFKA/KIP-954%3A+expand+default+DSL+store+configuration+to+custom+types)
### Testing Strategy
* Updated the topology tests to ensure that the configuration is picked up in the topology builder
* Manually built a Kafka Streams application using a customer `DslStoreSuppliers` class and verified that it was used
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1499784399
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
Great news! I just matched what was already in this file, but for future reference it's alright to mix EasyMock/Mockito in the same test files?
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1499955177
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
We avoid mixing, but this file didn't have any EasyMock before (as you said in your second comment). Feel free so submit a follow-up that changes it to Mockito. :)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on PR #14648:
URL: https://github.com/apache/kafka/pull/14648#issuecomment-1819878453
Haha yeah it's certainly grown quite a lot over the past few updates -- but for that reason I'm actually fine with keeping it in one PR. The first time I reviewed it there was significantly fewer LOC and I've just been looking at the updates since then. So no worries
(If you just threw this PR at me right out of the gate, that'd be a different story lol)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396321548
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
public static final String IN_MEMORY = "in_memory";
+ /** {@code dsl.store.suppliers.class } */
+ public static final String DSL_STORE_SUPPLIERS_CLASS_CONFIG = "dsl.store.suppliers.class";
+ public static final String DSL_STORE_SUPPLIERS_CLASS_DOC = "Defines which store implementations to plug in to DSL operators. Must implement the <code>org.apache.kafka.streams.state.DslStoreSuppliers</code> interface.";
+ public static final Class<?> DSL_STORE_SUPPLIERS_CLASS_DEFAULT = BuiltinDslStoreSuppliers.RocksDbDslStoreSuppliers.class;
Review Comment:
I switched it to string but the ergonomics around it are way worse since I have to do a bunch of manual validation that the config object would do for me. Is there really a reason not to use Class? Even things like the (required) key/value serde configurations are configured as Class:
```
.define(DEFAULT_KEY_SERDE_CLASS_CONFIG,
Type.CLASS,
null,
Importance.MEDIUM,
DEFAULT_KEY_SERDE_CLASS_DOC)
```
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398270071
##########
streams/src/main/java/org/apache/kafka/streams/state/DslSessionParams.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslSessionParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#sessionStore(DslSessionParams)}.
+ */
+public class DslSessionParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final EmitStrategy emitStrategy;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least as long enough to
+ * contain the inactivity gap of the session and the entire grace period.)
+ * @param emitStrategy defines how to emit results
+ */
+ public DslSessionParams(
+ final String name,
+ final Duration retentionPeriod,
+ final EmitStrategy emitStrategy
+ ) {
+ Objects.requireNonNull(name);
+ this.name = name;
+ this.retentionPeriod = retentionPeriod;
+ this.emitStrategy = emitStrategy;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public Duration retentionPeriod() {
+ return retentionPeriod;
+ }
+
+ public EmitStrategy emitStrategy() {
+ return emitStrategy;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final DslSessionParams that = (DslSessionParams) o;
+ return Objects.equals(name, that.name)
+ && Objects.equals(retentionPeriod, that.retentionPeriod)
+ && Objects.equals(emitStrategy, that.emitStrategy);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, retentionPeriod, emitStrategy);
+ }
+
+ @Override
+ public String toString() {
+ return "DslSessionParams{" +
+ "name='" + name + '\'' +
Review Comment:
It's autogenerated from intelliJ to indicate that `name` is a String (basically it formats it as "name='foo'". it isn't necessary (in fact it would be wrong) for non-string fields
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399973308
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:
##########
@@ -91,11 +91,13 @@ private KeyValueStore<Bytes, byte[]> maybeWrapLogging(final KeyValueStore<Bytes,
}
private final static class InMemoryTimestampedKeyValueStoreMarker
+ extends WrappedStateStore<KeyValueStore<Bytes, byte[]>, Bytes, byte[]>
Review Comment:
ah, ok, that makes sense. In that case yeah, can you just make a quick pass and update the calls in this? thanks!
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398539065
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
Ah, that's ok then. I had assumed you wrote this and that it was just for this class
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1393194762
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
public static final String IN_MEMORY = "in_memory";
+ /** {@code dsl.store.suppliers.class } */
+ public static final String DSL_STORE_SUPPLIERS_CLASS_CONFIG = "dsl.store.suppliers.class";
+ public static final String DSL_STORE_SUPPLIERS_CLASS_DOC = "Defines which store implementations to plug in to DSL operators. Must implement the <code>org.apache.kafka.streams.state.DslStoreSuppliers</code> interface.";
Review Comment:
kept package private so it can be used in `TopologyConfig` as well
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396493242
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
Does this method even need to be in the `TopologyConfig` class? Seems like we should be able to do everything here from some static utility, in which case we don't need this.
We definitely have a real problem with mixing up utility methods that are meant for internal use only with the by-definition public interface of the XXXConfig API. The Config classes just have some real fundamental abstractions issues. But we should try not to make the problem any worse at least, if we can help it.
(In fact Matthias has a PR/draft KIP to clean up StreamsConfig: https://github.com/apache/kafka/pull/14548)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396641005
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
note that `isTopologyOverride` is a private helper method, it's not exposed. :/ looks like none of the options are particularly good here
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396551006
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
> having the dslStoreSuppliers field be nullable
This is technically a different part of the code but on the subject of it being nullable... see https://github.com/apache/kafka/pull/14648#discussion_r1396543979
Anyways I personally feel like it would be preferable to expose the globalAppConfigs over the entire thing, or better yet, something like this which at least kind of makes sense as a generally-useful public API:
```
public boolean isGlobalOverride(final String config) {
return globalAppconfigs.originals().containsKey(config);
}
```
Basically something that mirrors the `isTopologyOverride`, which presumably we also need. Just a thought.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1397982732
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreFactory.java:
##########
@@ -66,6 +66,10 @@ default void configure(final StreamsConfig config) {
boolean isVersionedStore();
+ // TODO: consider moving all the log configuration code (InternalTopicConfig)
Review Comment:
this would be a great cleanup, I'm definitely not a fan of the `#isWindowStore` and `retentionPeriod` logic which kind of breaks the abstraction.
Just wondering, would we also be able to get rid of the `#historyRetention` and `#isVersionedStore` or is that used for something else?
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
Thanks!
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
Ah....in that case I would say just do whatever is easiest and cleanest for now (so presumably, just making this public)
If this class was intended to be a real and lasting public interface then it's probably neater to just have `isTopologyOverride` and `isGlobalOverride` as public APIs and then do the actual DslStoreSupplier resolution in an internal utility class. But I think we'll want to just deprecate/remove this entire class soon anyways, so it doesn't really hurt to have one more ugly API if we consider it effectively temporary. Maybe Matthias can even tackle this (deprecating TopologyConfig) in the KIP he was planning to clean up similar ugly APIs over in StreamsConfig -- I'll bring it up with him.
FYI though it's probably worth defending this choice when you update the KIP thread, with some form of the above argument. It's definitely not a good public interface but the whole thing needs to go and we can deprecate it all together
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreFactory.java:
##########
@@ -66,6 +66,10 @@ default void configure(final StreamsConfig config) {
boolean isVersionedStore();
+ // TODO: consider moving all the log configuration code (InternalTopicConfig)
Review Comment:
Btw unless you plan on doing it yourself in an immediate followup PR, please remove the TODO and file a JIRA ticket for this. As a general AK practice we don't leave inline TODOs unless they help to understand why we are currently doing something in a particular way (ie if it also makes sense as a non-TODO code comment then it's probably a good TODO as well)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396586675
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
no, it's not new logic -- it was respected in a roundabout way earlier that isn't respected after the refactoring of it into a StoreFactory
(namely, it was done in the WindowStoreBuilder but now that builder isn't called until after the topic is created)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1397992729
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltInDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltInDslStoreSuppliers {
Review Comment:
I think we should probably have javadocs for this class and the two built-in implementations. They can be brief but should cover at least how/where to use them:
1. how to configure an app-wide global default (including the config name)
2. how to configure individual operators via Materialized and StreamJoined
3. the hierarchy of preference if specified in multiple places (ie StreamJoined/Materialized overrides configured global default overrides unconfigured Streams default
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398281111
##########
streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java:
##########
@@ -1038,13 +1038,15 @@ public void shouldThrowConfigExceptionWhenOptimizationConfigNotValueInRange() {
assertThrows(ConfigException.class, () -> new StreamsConfig(props));
}
+ @SuppressWarnings("deprecation")
@Test
public void shouldSpecifyRocksdbWhenNotExplicitlyAddedToConfigs() {
final String expectedDefaultStoreType = StreamsConfig.ROCKS_DB;
final String actualDefaultStoreType = streamsConfig.getString(DEFAULT_DSL_STORE_CONFIG);
assertEquals("default.dsl.store should be \"rocksDB\"", expectedDefaultStoreType, actualDefaultStoreType);
}
+ @SuppressWarnings("deprecation")
@Test
public void shouldSpecifyInMemoryWhenExplicitlyAddedToConfigs() {
Review Comment:
done
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398002738
##########
streams/src/main/java/org/apache/kafka/streams/state/DslSessionParams.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslSessionParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#sessionStore(DslSessionParams)}.
+ */
+public class DslSessionParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final EmitStrategy emitStrategy;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least as long enough to
+ * contain the inactivity gap of the session and the entire grace period.)
+ * @param emitStrategy defines how to emit results
+ */
+ public DslSessionParams(
+ final String name,
+ final Duration retentionPeriod,
+ final EmitStrategy emitStrategy
+ ) {
+ Objects.requireNonNull(name);
+ this.name = name;
+ this.retentionPeriod = retentionPeriod;
+ this.emitStrategy = emitStrategy;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public Duration retentionPeriod() {
+ return retentionPeriod;
+ }
+
+ public EmitStrategy emitStrategy() {
+ return emitStrategy;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final DslSessionParams that = (DslSessionParams) o;
+ return Objects.equals(name, that.name)
+ && Objects.equals(retentionPeriod, that.retentionPeriod)
+ && Objects.equals(emitStrategy, that.emitStrategy);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, retentionPeriod, emitStrategy);
+ }
+
+ @Override
+ public String toString() {
+ return "DslSessionParams{" +
+ "name='" + name + '\'' +
Review Comment:
what's with the `+ '\''` (guessing a copy/paste error?)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398002400
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltInDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltInDslStoreSuppliers {
Review Comment:
Actually maybe the stuff I listed above should be in the `DslStoreSuppliers` interface javadocs instead of here. But I still think this class should have javadocs, even just a sentence or two
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396641719
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
Also see the TODO i added on StoreFactory and LMKWYT
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396517053
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
we can, the alternative though is having the `dslStoreSuppliers` field be nullable -- I'm not sure what's prefereable.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396586675
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
no, it's not new logic -- it was respected in a roundabout way earlier that isn't respected after the refactoring of it into a StoreFactory
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1499780993
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
We should be using `mockito` for new tests. A large number of tests have been converted (a huge amount of work) - this is adding more conversion work. cc @divijvaidya
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396641322
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -16,17 +16,21 @@
*/
package org.apache.kafka.streams;
+import java.util.Optional;
Review Comment:
AK should really have a checkstyle rule for imports! I've accidentally messed this up a few times already
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398012157
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
One more thing: since we leave the `streamJoined.thisStoreSupplier` as null if not specified (rather than, say, defaulting it to a rocksdb supplier), then we should be able to differentiate when `thisStoreSupplier` was explicitly set, and therefore should respect when it is set to a RocksDBBytesStoreSupplier. In other words, we can remove the in-memory specific handling and just check if `streamJoined.thisStoreSupplier() != null` and use it if so
That said....I actually think it would be more correct to select the store type according to this ordering:
1. if the `StreamJoined#dslStoreSuppliers` is non-null, use this to get the kv store
2. if the `StreamJoined#thisStoreSupplier` is non-null, and is either rocksdb or in-memory, use a store of the same type
3. Otherwise fall back on the `dsl.store.suppliers` config (whether explicitly configured or the default)
That said, if this is going to be a challenge to implement, I do think it's acceptable to swap the priority of 1 & 2. Either way, we should make sure to respect rocksdb as well as in-memory for `thisStoreSupplier`
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398269890
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreFactory.java:
##########
@@ -66,6 +66,10 @@ default void configure(final StreamsConfig config) {
boolean isVersionedStore();
+ // TODO: consider moving all the log configuration code (InternalTopicConfig)
Review Comment:
> Just wondering, would we also be able to get rid of the #historyRetention and #isVersionedStore or is that used for something else?
we would with a little bit more abstraction/refactoring. they are used somewhere to check configurations but I think it makes sense to push that into this class as well and get rid of that too.
> Btw unless you plan on doing it yourself in an immediate followup PR
I am happy to do that, I checked the code and found quite a few TODOs so I assumed it was OK. I'll just remove the TODO and file a JIRA.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398306353
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
+1 ! Likes the proposed ordering.
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
I'm a bit inclined with adding such an `resolveDslStoreSuppliers` to `StreamsConfig` directly as long as we label it EVOLVING to leave us options to delete it (of course this would need get other's opinion as we update the KIP DISCUSS thread), until we have a clear clue on what we want to expose eventually.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on PR #14648:
URL: https://github.com/apache/kafka/pull/14648#issuecomment-1821731448
Looks like all the builds are compiling, but we have 18 flaky tests. I checked all of them and none seem to be related to this PR. I also haven't seen any concerns about any of the updates on the KIP discussion thread, so I think we can go ahead with merging it
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399812871
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.DslStoreSuppliers;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.RocksDbWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private final DslStoreSuppliers streamJoinedDslStoreSuppliers;
+
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+
+ // we store this one manually instead of relying on super#dslStoreSuppliers()
+ // so that we can differentiate between one that was explicitly passed in and
+ // one that was configured via super#configure()
+ this.streamJoinedDslStoreSuppliers = streamJoined.dslStoreSuppliers();
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ final KeyValueBytesStoreSupplier supplier;
+
+ if (streamJoinedDslStoreSuppliers != null) {
Review Comment:
nice! This is finally looking good -- besides just doing the correct thing, it feels a lot easier to verify the logic now. And the clear comments definitely help
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396482901
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
public static final String IN_MEMORY = "in_memory";
+ /** {@code dsl.store.suppliers.class } */
+ public static final String DSL_STORE_SUPPLIERS_CLASS_CONFIG = "dsl.store.suppliers.class";
+ public static final String DSL_STORE_SUPPLIERS_CLASS_DOC = "Defines which store implementations to plug in to DSL operators. Must implement the <code>org.apache.kafka.streams.state.DslStoreSuppliers</code> interface.";
+ public static final Class<?> DSL_STORE_SUPPLIERS_CLASS_DEFAULT = BuiltinDslStoreSuppliers.RocksDbDslStoreSuppliers.class;
Review Comment:
Ah, sorry, maybe I mislead you here...if it's easier to work with the `Class` directly then go ahead with that
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396517053
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
we can, the alternative though is having the `dslStoreSuppliers` field be nullable -- I'm not sure what's prefereable.
EDIT: we'll also need to expose the globalAppConfigs (which is currently private)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396590225
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
> It's stemming from the fact that we always initialize the dslStoreSuppliers in StreamJoined to the default Materialized.StoreType.ROCKS_DB if not explicitly configured.
Ah good catch! I should be leaving that as null as the call to `configure` will properly resolve this in `AbstractConfigurableStoreFactory`.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398003330
##########
streams/src/main/java/org/apache/kafka/streams/state/DslSessionParams.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslSessionParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#sessionStore(DslSessionParams)}.
+ */
+public class DslSessionParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final EmitStrategy emitStrategy;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least as long enough to
+ * contain the inactivity gap of the session and the entire grace period.)
+ * @param emitStrategy defines how to emit results
+ */
+ public DslSessionParams(
+ final String name,
+ final Duration retentionPeriod,
+ final EmitStrategy emitStrategy
+ ) {
+ Objects.requireNonNull(name);
+ this.name = name;
+ this.retentionPeriod = retentionPeriod;
+ this.emitStrategy = emitStrategy;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public Duration retentionPeriod() {
+ return retentionPeriod;
+ }
+
+ public EmitStrategy emitStrategy() {
+ return emitStrategy;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final DslSessionParams that = (DslSessionParams) o;
+ return Objects.equals(name, that.name)
+ && Objects.equals(retentionPeriod, that.retentionPeriod)
+ && Objects.equals(emitStrategy, that.emitStrategy);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, retentionPeriod, emitStrategy);
+ }
+
+ @Override
+ public String toString() {
+ return "DslSessionParams{" +
+ "name='" + name + '\'' +
Review Comment:
Actually looks like we have it in the KV and Window params as well. If it's intentional it should probably be on every line, but I'm guessing it's not?
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398003882
##########
streams/src/main/java/org/apache/kafka/streams/state/DslStoreSuppliers.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.state;
+
+import java.util.Map;
+import org.apache.kafka.common.Configurable;
+
+/**
+ * {@code DslStoreSuppliers} defines a grouping of factories to construct
+ * stores for each of the types of state store implementations in Kafka
+ * Streams. This allows configuration of a default store supplier beyond
+ * the builtin defaults of RocksDB and In-Memory.
Review Comment:
I think we should be a bit more explicit about how this gets used, see https://github.com/apache/kafka/pull/14648/files#r1397992729
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398006947
##########
streams/src/test/java/org/apache/kafka/streams/StreamsConfigTest.java:
##########
@@ -1038,13 +1038,15 @@ public void shouldThrowConfigExceptionWhenOptimizationConfigNotValueInRange() {
assertThrows(ConfigException.class, () -> new StreamsConfig(props));
}
+ @SuppressWarnings("deprecation")
@Test
public void shouldSpecifyRocksdbWhenNotExplicitlyAddedToConfigs() {
final String expectedDefaultStoreType = StreamsConfig.ROCKS_DB;
final String actualDefaultStoreType = streamsConfig.getString(DEFAULT_DSL_STORE_CONFIG);
assertEquals("default.dsl.store should be \"rocksDB\"", expectedDefaultStoreType, actualDefaultStoreType);
}
+ @SuppressWarnings("deprecation")
@Test
public void shouldSpecifyInMemoryWhenExplicitlyAddedToConfigs() {
Review Comment:
Can you add some basic tests for the new store config? Basically something like what we have for the old configs -- ie the default is rocksdb and that the built-in InMemoryDslStoreSuppliers -- but instead of the bad-enum one, just make sure you can actually pass in a custom implementation
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396638341
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
Fixed and added a test for it as well
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396484290
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltinDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltinDslStoreSuppliers {
+
+ public static final DslStoreSuppliers ROCKS_DB = new RocksDbDslStoreSuppliers();
+ public static final DslStoreSuppliers IN_MEMORY = new InMemoryDslStoreSuppliers();
+
+ public static class RocksDbDslStoreSuppliers implements DslStoreSuppliers {
Review Comment:
Ah, fair enough...well just personally I think it looks better capitalized but I guess we should just make a pass to converge all the class names one way or another. Not a big deal at all though
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1393203579
##########
streams/src/main/java/org/apache/kafka/streams/kstream/Materialized.java:
##########
@@ -97,21 +128,21 @@ protected Materialized(final Materialized<K, V, S> materialized) {
this.cachingEnabled = materialized.cachingEnabled;
this.topicConfig = materialized.topicConfig;
this.retention = materialized.retention;
- this.storeType = materialized.storeType;
+ this.storeSuppliers = materialized.storeSuppliers;
}
/**
- * Materialize a {@link StateStore} with the given {@link StoreType}.
+ * Materialize a {@link StateStore} with the given {@link DslStoreSuppliers}.
*
- * @param storeType the type of the state store
- * @param <K> key type of the store
- * @param <V> value type of the store
- * @param <S> type of the {@link StateStore}
+ * @param storeSuppliers the type of the state store
+ * @param <K> key type of the store
+ * @param <V> value type of the store
+ * @param <S> type of the {@link StateStore}
* @return a new {@link Materialized} instance with the given storeName
*/
- public static <K, V, S extends StateStore> Materialized<K, V, S> as(final StoreType storeType) {
- Objects.requireNonNull(storeType, "store type can't be null");
- return new Materialized<>(storeType);
+ public static <K, V, S extends StateStore> Materialized<K, V, S> as(final DslStoreSuppliers storeSuppliers) {
Review Comment:
yup!
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399930568
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:
##########
@@ -91,11 +91,13 @@ private KeyValueStore<Bytes, byte[]> maybeWrapLogging(final KeyValueStore<Bytes,
}
private final static class InMemoryTimestampedKeyValueStoreMarker
+ extends WrappedStateStore<KeyValueStore<Bytes, byte[]>, Bytes, byte[]>
Review Comment:
yes it was, we needed it in order to pass the tests that I added which check that `InMemoryXStore` is in the store heirarchy - otherwise it would stop at this change
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:
##########
@@ -91,11 +91,13 @@ private KeyValueStore<Bytes, byte[]> maybeWrapLogging(final KeyValueStore<Bytes,
}
private final static class InMemoryTimestampedKeyValueStoreMarker
+ extends WrappedStateStore<KeyValueStore<Bytes, byte[]>, Bytes, byte[]>
Review Comment:
yes it was, we needed it in order to pass the tests that I added which check that `InMemoryXStore` is in the store heirarchy - otherwise it would stop at this level
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398539065
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
Ah, that's ok then, I thought you wrote this just for this class
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1377093727
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
public static final String IN_MEMORY = "in_memory";
+ /** {@code dsl.store.suppliers.class } */
+ public static final String DSL_STORE_SUPPLIERS_CLASS_CONFIG = "dsl.store.suppliers.class";
+ public static final String DSL_STORE_SUPPLIERS_CLASS_DOC = "Defines which store implementations to plug in to DSL operators. Must implement the <code>org.apache.kafka.streams.state.DslStoreSuppliers</code> interface.";
Review Comment:
nit: the doc string and default can (and probably should) just be `private`. Not a big deal but it keeps them out of the official public API and helps avoid awkward/annoying trivial things like having to deprecate all of these as well, not being able to move/rename if necessary, you get the idea
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -209,19 +219,22 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
deserializationExceptionHandlerSupplier = () -> globalAppConfigs.getConfiguredInstance(DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG, DeserializationExceptionHandler.class);
}
- if (isTopologyOverride(DEFAULT_DSL_STORE_CONFIG, topologyOverrides)) {
- storeType = getString(DEFAULT_DSL_STORE_CONFIG);
+ // prefer dsl.store.suppliers.class to default.dsl.store and prefer topology overrides over
+ // the global streams configuration
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ storeSuppliers = (DslStoreSuppliers) Utils.newInstance(getClass(DSL_STORE_SUPPLIERS_CLASS_CONFIG));
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, storeSuppliers);
+ } else if (isTopologyOverride(DEFAULT_DSL_STORE_CONFIG, topologyOverrides)) {
+ final String storeType = getString(DEFAULT_DSL_STORE_CONFIG);
+ storeSuppliers = storeType.equals(IN_MEMORY) ? Materialized.StoreType.IN_MEMORY : Materialized.StoreType.ROCKS_DB;
log.info("Topology {} is overriding {} to {}", topologyName, DEFAULT_DSL_STORE_CONFIG, storeType);
} else {
- storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
+ storeSuppliers = (DslStoreSuppliers) Utils.newInstance(globalAppConfigs.getClass(DSL_STORE_SUPPLIERS_CLASS_CONFIG));
Review Comment:
I feel like we're missing a branch here -- if someone is using the old `default.dsl.store` but only sets it in their global app configs (ie via `new KafkaStreams(...)`) and sets neither of these configs in their topology configs (ie `new StreamsBuilder(...)`), then we should still respect the old config and fall back on that in the global app configs
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
Review Comment:
IIRC we decided to deprecate the old config, in which case we should make sure to add a `@Deprecated` tag to the config name and these two options. I guess since the doc string is public it should technically also be deprecated...
##########
streams/src/main/java/org/apache/kafka/streams/kstream/Materialized.java:
##########
@@ -97,21 +128,21 @@ protected Materialized(final Materialized<K, V, S> materialized) {
this.cachingEnabled = materialized.cachingEnabled;
this.topicConfig = materialized.topicConfig;
this.retention = materialized.retention;
- this.storeType = materialized.storeType;
+ this.storeSuppliers = materialized.storeSuppliers;
}
/**
- * Materialize a {@link StateStore} with the given {@link StoreType}.
+ * Materialize a {@link StateStore} with the given {@link DslStoreSuppliers}.
*
- * @param storeType the type of the state store
- * @param <K> key type of the store
- * @param <V> value type of the store
- * @param <S> type of the {@link StateStore}
+ * @param storeSuppliers the type of the state store
+ * @param <K> key type of the store
+ * @param <V> value type of the store
+ * @param <S> type of the {@link StateStore}
* @return a new {@link Materialized} instance with the given storeName
*/
- public static <K, V, S extends StateStore> Materialized<K, V, S> as(final StoreType storeType) {
- Objects.requireNonNull(storeType, "store type can't be null");
- return new Materialized<>(storeType);
+ public static <K, V, S extends StateStore> Materialized<K, V, S> as(final DslStoreSuppliers storeSuppliers) {
Review Comment:
Just to clarify (for myself as well as anyone else reviewing this), we are able to simply swap in the new `DSLStoreSuppliers` parameter -- instead of deprecating this and adding a new API -- because source-code compatibility is maintained due to the new `StoreType` inheritance.
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/SessionWindowedCogroupedKStreamImpl.java:
##########
@@ -106,7 +108,7 @@ public KTable<Windowed<K>, V> aggregate(final Initializer<V> initializer,
sessionMerger);
}
- private StoreBuilder<SessionStore<K, V>> materialize(final MaterializedInternal<K, V, SessionStore<Bytes, byte[]>> materialized) {
+ private StoreBuilder<SessionStore<K, V>> materialize(final MaterializedInternal<K, V, SessionStore<Bytes, byte[]>> materialized) {
SessionBytesStoreSupplier supplier = (SessionBytesStoreSupplier) materialized.storeSupplier();
if (supplier == null) {
Review Comment:
ditto here -- seems like we can simplify things to make the `supplier` variable final.
I'm going to stop commenting on this because I suspect the pattern repeats a lot, so I'll leave it up to you to make a pass over the rest. And I know it feels petty, but given the logic around initializing and properly configuring the default store suppliers is relatively complex, I actually do believe there's value in trying to make things as straightforward as possible, including using `final` variables for things like this.
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltinDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltinDslStoreSuppliers {
Review Comment:
nit: seems like we capitalize the "I" in "BuiltIn" for other public APIs that have this in the name -- not a huge deal but probably best to be consistent
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KeyValueStoreMaterializer.java:
##########
@@ -46,16 +47,9 @@ public KeyValueStoreMaterializer(final MaterializedInternal<K, V, KeyValueStore<
public StoreBuilder<?> materialize() {
KeyValueBytesStoreSupplier supplier = (KeyValueBytesStoreSupplier) materialized.storeSupplier();
if (supplier == null) {
- switch (materialized.storeType()) {
- case IN_MEMORY:
- supplier = Stores.inMemoryKeyValueStore(materialized.storeName());
- break;
- case ROCKS_DB:
- supplier = Stores.persistentTimestampedKeyValueStore(materialized.storeName());
- break;
- default:
- throw new IllegalStateException("Unknown store type: " + materialized.storeType());
- }
+ supplier = materialized.storeSuppliers.keyValueStore(
Review Comment:
nit: since we simplified this part of the code so much, can we go one step further and refactor so that the `supplier` variable is final?
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -536,6 +537,11 @@ public class StreamsConfig extends AbstractConfig {
public static final String ROCKS_DB = "rocksDB";
public static final String IN_MEMORY = "in_memory";
+ /** {@code dsl.store.suppliers.class } */
+ public static final String DSL_STORE_SUPPLIERS_CLASS_CONFIG = "dsl.store.suppliers.class";
+ public static final String DSL_STORE_SUPPLIERS_CLASS_DOC = "Defines which store implementations to plug in to DSL operators. Must implement the <code>org.apache.kafka.streams.state.DslStoreSuppliers</code> interface.";
+ public static final Class<?> DSL_STORE_SUPPLIERS_CLASS_DEFAULT = BuiltinDslStoreSuppliers.RocksDbDslStoreSuppliers.class;
Review Comment:
Frankly idk how much it matters, or even if it does at all, but generally we use the class name (ie a `String` for configs whenever possible, eg for defaults. It's just easier to work with strings (and I have a small nagging sense that we may autogenerate docs based on the code here which might struggle with the `Class` variant vs the `String` class name...but I'm not 100% sure)
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -117,7 +127,7 @@ public class TopologyConfig extends AbstractConfig {
public final long cacheSize;
public final long maxTaskIdleMs;
public final long taskTimeoutMs;
- public final String storeType;
+ private final DslStoreSuppliers storeSuppliers;
Review Comment:
why is only this field `private`?
(I suspect the answer is that they should all be private but we just use this class as a loose container object that doesn't bother with getters. Even so, let's just conform to the current pattern and make this public like the rest)
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -209,19 +219,22 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
deserializationExceptionHandlerSupplier = () -> globalAppConfigs.getConfiguredInstance(DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG, DeserializationExceptionHandler.class);
}
- if (isTopologyOverride(DEFAULT_DSL_STORE_CONFIG, topologyOverrides)) {
- storeType = getString(DEFAULT_DSL_STORE_CONFIG);
+ // prefer dsl.store.suppliers.class to default.dsl.store and prefer topology overrides over
+ // the global streams configuration
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ storeSuppliers = (DslStoreSuppliers) Utils.newInstance(getClass(DSL_STORE_SUPPLIERS_CLASS_CONFIG));
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, storeSuppliers);
+ } else if (isTopologyOverride(DEFAULT_DSL_STORE_CONFIG, topologyOverrides)) {
+ final String storeType = getString(DEFAULT_DSL_STORE_CONFIG);
+ storeSuppliers = storeType.equals(IN_MEMORY) ? Materialized.StoreType.IN_MEMORY : Materialized.StoreType.ROCKS_DB;
log.info("Topology {} is overriding {} to {}", topologyName, DEFAULT_DSL_STORE_CONFIG, storeType);
} else {
- storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
+ storeSuppliers = (DslStoreSuppliers) Utils.newInstance(globalAppConfigs.getClass(DSL_STORE_SUPPLIERS_CLASS_CONFIG));
}
}
- public Materialized.StoreType parseStoreType() {
- if (storeType.equals(IN_MEMORY)) {
- return Materialized.StoreType.IN_MEMORY;
- }
- return Materialized.StoreType.ROCKS_DB;
+ public DslStoreSuppliers getStoreSuppliers() {
Review Comment:
```suggestion
public DslStoreSuppliers storeSuppliers() {
```
Style rule (no `get` in Streams getters)
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltinDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltinDslStoreSuppliers {
+
+ public static final DslStoreSuppliers ROCKS_DB = new RocksDbDslStoreSuppliers();
+ public static final DslStoreSuppliers IN_MEMORY = new InMemoryDslStoreSuppliers();
+
+ public static class RocksDbDslStoreSuppliers implements DslStoreSuppliers {
Review Comment:
another naming nit: we always capitalize the "B" in "RocksDB" in class names
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399820405
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedInternal.java:
##########
@@ -18,16 +18,30 @@
package org.apache.kafka.streams.kstream.internals;
import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.TopologyConfig;
import org.apache.kafka.streams.kstream.StreamJoined;
+import org.apache.kafka.streams.state.DslStoreSuppliers;
import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
import java.util.Map;
public class StreamJoinedInternal<K, V1, V2> extends StreamJoined<K, V1, V2> {
+ private final InternalStreamsBuilder builder;
+
//Needs to be public for testing
- public StreamJoinedInternal(final StreamJoined<K, V1, V2> streamJoined) {
+ public StreamJoinedInternal(
+ final StreamJoined<K, V1, V2> streamJoined,
+ final InternalStreamsBuilder builder
+ ) {
super(streamJoined);
+ this.builder = builder;
+ if (dslStoreSuppliers == null) {
+ final TopologyConfig topologyConfig = builder.internalTopologyBuilder.topologyConfigs();
+ if (topologyConfig != null) {
+ dslStoreSuppliers = topologyConfig.resolveDslStoreSuppliers().orElse(null);
+ }
Review Comment:
Hm...is this logic correct in the context of the initialization logic in [OuterStreamJoinedStoreFactory](https://github.com/apache/kafka/pull/14648/files#r1399812871)
My read of that code, specifically case 1, was that we interpret `streamJoined#dslStoreSuppliers` as what the user passed in to the StreamJoined, so it should be null (and stay null) if the user didn't explicitly configure a dslStoreSuppliers.
Then in case 3 (or the else branch of case 2), we fall back to the config value if neither the `dslStoreSuppliers` or the `thisStoreSupplier` of the StreamJoined was set/non-null
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedInternal.java:
##########
@@ -18,16 +18,30 @@
package org.apache.kafka.streams.kstream.internals;
import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.TopologyConfig;
import org.apache.kafka.streams.kstream.StreamJoined;
+import org.apache.kafka.streams.state.DslStoreSuppliers;
import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
import java.util.Map;
public class StreamJoinedInternal<K, V1, V2> extends StreamJoined<K, V1, V2> {
+ private final InternalStreamsBuilder builder;
+
//Needs to be public for testing
- public StreamJoinedInternal(final StreamJoined<K, V1, V2> streamJoined) {
+ public StreamJoinedInternal(
+ final StreamJoined<K, V1, V2> streamJoined,
+ final InternalStreamsBuilder builder
+ ) {
super(streamJoined);
+ this.builder = builder;
+ if (dslStoreSuppliers == null) {
+ final TopologyConfig topologyConfig = builder.internalTopologyBuilder.topologyConfigs();
+ if (topologyConfig != null) {
+ dslStoreSuppliers = topologyConfig.resolveDslStoreSuppliers().orElse(null);
+ }
Review Comment:
Hm...is this logic correct in the context of the initialization logic in [OuterStreamJoinedStoreFactory](https://github.com/apache/kafka/pull/14648/files#r1399812871)?
My read of that code, specifically case 1, was that we interpret `streamJoined#dslStoreSuppliers` as what the user passed in to the StreamJoined, so it should be null (and stay null) if the user didn't explicitly configure a dslStoreSuppliers.
Then in case 3 (or the else branch of case 2), we fall back to the config value if neither the `dslStoreSuppliers` or the `thisStoreSupplier` of the StreamJoined was set/non-null
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399821160
##########
streams/src/main/java/org/apache/kafka/streams/state/DslStoreSuppliers.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.state;
+
+import java.util.Map;
+import org.apache.kafka.common.Configurable;
+
+/**
+ * {@code DslStoreSuppliers} defines a grouping of factories to construct
+ * stores for each of the types of state store implementations in Kafka
+ * Streams. This allows configuration of a default store supplier beyond
+ * the builtin defaults of RocksDB and In-Memory.
Review Comment:
This looks great, thanks!
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman merged PR #14648:
URL: https://github.com/apache/kafka/pull/14648
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398269442
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
There is a test for it (not added in this PR)! that's how it caught this bug ;) I don't remember which file it's in though.. if I figure it out I'll link it here
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398004582
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
this is kind of a roundabout way of saying it must be at least equal to the windowSize + gracePeriod. I think it's better to just explicitly state this and put the constraint in concrete terms relative to other known quantities
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398270264
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
this was copied from javadoc elsewhere - see `Stores#persistentWindowStore`. if we want to change it we can do that in a separate PR so it's consistent throughout the board
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on PR #14648:
URL: https://github.com/apache/kafka/pull/14648#issuecomment-1819373423
@guozhangwang I feel bad having such a large PR! It's grown slowly over review cycles from ~500 lines to where it is now 😅
@ableegoldman I'm happy to split the PR into two now that's grown quite a bit (though a good chunk of the lines are tests/license text), but since you've reviewed it as it's grown let me know if you're OK keeping the PR at this size.
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1499787175
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
Ah it appears my memory is hazy - I'm not sure why I used EasyMock here...
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1398005349
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
Actually IIUC users should never have to instantiate these classes directly, so I guess it's not that critical to define the specific constraints and ok to describe it conceptually. Or both 🤷♀️
##########
streams/src/main/java/org/apache/kafka/streams/state/DslWindowParams.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.state;
+
+import java.time.Duration;
+import java.util.Objects;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+
+/**
+ * {@code DslWindowParams} is a wrapper class for all parameters that function
+ * as inputs to {@link DslStoreSuppliers#windowStore(DslWindowParams)}.
+ */
+public class DslWindowParams {
+
+ private final String name;
+ private final Duration retentionPeriod;
+ private final Duration windowSize;
+ private final boolean retainDuplicates;
+ private final EmitStrategy emitStrategy;
+ private final boolean isSlidingWindow;
+
+ /**
+ * @param name name of the store (cannot be {@code null})
+ * @param retentionPeriod length of time to retain data in the store (cannot be negative)
+ * (note that the retention period must be at least long enough to contain the
+ * windowed data's entire life cycle, from window-start through window-end,
+ * and for the entire grace period)
Review Comment:
Actually IIUC users should never have to instantiate these classes directly, so I guess it's not that critical to define the specific constraints and ok to describe it conceptually. Or both 🤷♀️
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396507648
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -16,17 +16,21 @@
*/
package org.apache.kafka.streams;
+import java.util.Optional;
Review Comment:
nit: out of order
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/graph/StreamStreamJoinNode.java:
##########
@@ -227,9 +223,9 @@ public StreamStreamJoinNode<K, V1, V2, VR> build() {
joinMergeProcessorParameters,
thisWindowedStreamProcessorParameters,
otherWindowedStreamProcessorParameters,
- thisWindowStoreBuilder,
- otherWindowStoreBuilder,
- outerJoinWindowStoreBuilder,
+ thisStoreFactory,
+ otherStoreFactory,
Review Comment:
nit: formatting
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/OuterStreamJoinStoreFactory.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import static org.apache.kafka.streams.internals.ApiUtils.prepareMillisCheckFailMsgPrefix;
+import static org.apache.kafka.streams.internals.ApiUtils.validateMillisecondDuration;
+
+import java.time.Duration;
+import java.util.Map;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslKeyValueParams;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.KeyValueStore;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.LeftOrRightValue;
+import org.apache.kafka.streams.state.internals.LeftOrRightValueSerde;
+import org.apache.kafka.streams.state.internals.ListValueStoreBuilder;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSide;
+import org.apache.kafka.streams.state.internals.TimestampedKeyAndJoinSideSerde;
+
+public class OuterStreamJoinStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final StreamJoinedInternal<K, V1, V2> streamJoined;
+ private final JoinWindows windows;
+ private boolean loggingEnabled;
+
+ public enum Type {
+ RIGHT,
+ LEFT
+ }
+
+ public OuterStreamJoinStoreFactory(
+ final String name,
+ final StreamJoinedInternal<K, V1, V2> streamJoined,
+ final JoinWindows windows,
+ final Type type
+ ) {
+ super(streamJoined.dslStoreSuppliers());
+ this.name = buildOuterJoinWindowStoreName(streamJoined, name, type) + "-store";
+ this.streamJoined = streamJoined;
+ this.windows = windows;
+ this.loggingEnabled = streamJoined.loggingEnabled();
+ }
+
+ @Override
+ public StateStore build() {
+ final Duration retentionPeriod = Duration.ofMillis(retentionPeriod());
+ final Duration windowSize = Duration.ofMillis(windows.size());
+ final String rpMsgPrefix = prepareMillisCheckFailMsgPrefix(retentionPeriod, "retentionPeriod");
+ final long retentionMs = validateMillisecondDuration(retentionPeriod, rpMsgPrefix);
+ final String wsMsgPrefix = prepareMillisCheckFailMsgPrefix(windowSize, "windowSize");
+ final long windowSizeMs = validateMillisecondDuration(windowSize, wsMsgPrefix);
+
+ if (retentionMs < 0L) {
+ throw new IllegalArgumentException("retentionPeriod cannot be negative");
+ }
+ if (windowSizeMs < 0L) {
+ throw new IllegalArgumentException("windowSize cannot be negative");
+ }
+ if (windowSizeMs > retentionMs) {
+ throw new IllegalArgumentException("The retention period of the window store "
+ + name + " must be no smaller than its window size. Got size=["
+ + windowSizeMs + "], retention=[" + retentionMs + "]");
+ }
+
+ final TimestampedKeyAndJoinSideSerde<K> timestampedKeyAndJoinSideSerde = new TimestampedKeyAndJoinSideSerde<>(streamJoined.keySerde());
+ final LeftOrRightValueSerde<V1, V2> leftOrRightValueSerde = new LeftOrRightValueSerde<>(streamJoined.valueSerde(), streamJoined.otherValueSerde());
+
+ // TODO: we should allow for configuration of this store explicitly instead of assuming that it should
+ // share the same type of store as thisStoreSupplier
+ final boolean useInMemoryStore = streamJoined.thisStoreSupplier() != null
+ && streamJoined.thisStoreSupplier() instanceof InMemoryWindowBytesStoreSupplier;
+ final KeyValueBytesStoreSupplier supplier = useInMemoryStore
+ ? Stores.inMemoryKeyValueStore(name)
+ : dslStoreSuppliers().keyValueStore(new DslKeyValueParams(name));
Review Comment:
I think this is going to resolve to the wrong store type in two cases where it should, at least in theory, be possible to select the right one:
1) Users sets the global `dsl.store.suppliers` (ie the config) to an in-memory or custom store, but want to fix this stream-stream join to rocksdb. So `streamJoined.storeSupplier` == RocksdbBytesStoreSupplier
2) User sets a global `dsl.store.suppliers` and does not configure the StreamJoined with a `dslStoreSupplier`
Frankly 1) is probably not a big deal, but 2) seems like a more serious violation. It's stemming from the fact that we always initialize the `dslStoreSuppliers` in StreamJoined to the default `Materialized.StoreType.ROCKS_DB` if not explicitly configured. So the `streamJoined#dslStoreSuppliers` that we pass into the `AbstractConfigurableStoreFactory` constructor is never null, which means we'll always hit the `Materialized.StoreType.ROCKS_DB` and won't respect the user's global config
At least, that's my reading of the situation...it's a bit complex so maybe I missed something.
Seems like we'll need to either use a flag to mark when the user has explicitly set the StreamJoined's `dslStoreSuppliers`, or just leave it null if the user hasn't set it. The latter feels like the right thing to do but of course that has implications for the rest of the code. Can we make it work without initializing to the default RocksdbDslStoreSuppliers?
You know the code better than me so I'll leave that up to you, hopefully I got the point across here. At the very least, I guess we could just treat the RocksDB as a special case, and ignore the `StreamJoined#dslStoreSuppliers` in favor of the global default if it's equal to `Materialized.StoreType.ROCKS_DB`
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
Is this new logic? I don't think it hurts anything to have compaction enabled...of course it's also not doing anything so I guess this optimization makes sense
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399939069
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedInternal.java:
##########
@@ -18,16 +18,30 @@
package org.apache.kafka.streams.kstream.internals;
import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.TopologyConfig;
import org.apache.kafka.streams.kstream.StreamJoined;
+import org.apache.kafka.streams.state.DslStoreSuppliers;
import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
import java.util.Map;
public class StreamJoinedInternal<K, V1, V2> extends StreamJoined<K, V1, V2> {
+ private final InternalStreamsBuilder builder;
+
//Needs to be public for testing
- public StreamJoinedInternal(final StreamJoined<K, V1, V2> streamJoined) {
+ public StreamJoinedInternal(
+ final StreamJoined<K, V1, V2> streamJoined,
+ final InternalStreamsBuilder builder
+ ) {
super(streamJoined);
+ this.builder = builder;
+ if (dslStoreSuppliers == null) {
+ final TopologyConfig topologyConfig = builder.internalTopologyBuilder.topologyConfigs();
+ if (topologyConfig != null) {
+ dslStoreSuppliers = topologyConfig.resolveDslStoreSuppliers().orElse(null);
+ }
Review Comment:
nice catch! added a test and fixed it
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1399822846
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/TimestampedKeyValueStoreBuilder.java:
##########
@@ -91,11 +91,13 @@ private KeyValueStore<Bytes, byte[]> maybeWrapLogging(final KeyValueStore<Bytes,
}
private final static class InMemoryTimestampedKeyValueStoreMarker
+ extends WrappedStateStore<KeyValueStore<Bytes, byte[]>, Bytes, byte[]>
Review Comment:
was this related to the changes in this PR? if not, let's leave it out for now, especially as we'd probably want to clean it up a bit further and change the `wrapped` invocations to `super` throughout the class
but feel free to do a followup PR with this!
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1397987652
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/StreamJoinedStoreFactory.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.serialization.Serde;
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.kstream.JoinWindows;
+import org.apache.kafka.streams.processor.StateStore;
+import org.apache.kafka.streams.processor.internals.StoreFactory;
+import org.apache.kafka.streams.state.DslWindowParams;
+import org.apache.kafka.streams.state.StoreBuilder;
+import org.apache.kafka.streams.state.Stores;
+import org.apache.kafka.streams.state.WindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.WindowStore;
+
+public class StreamJoinedStoreFactory<K, V1, V2> extends AbstractConfigurableStoreFactory {
+
+ private final String name;
+ private final JoinWindows windows;
+ private final Serde<?> valueSerde;
+ private final WindowBytesStoreSupplier storeSupplier;
+ private final StreamJoinedInternal<K, V1, V2> joinedInternal;
+
+ private boolean loggingEnabled;
+ private final Map<String, String> logConfig;
+
+ public enum Type {
+ THIS,
+ OTHER
+ }
+
+ public StreamJoinedStoreFactory(
+ final String name,
+ final JoinWindows windows,
+ final StreamJoinedInternal<K, V1, V2> joinedInternal,
+ final Type type
+ ) {
+ super(joinedInternal.dslStoreSuppliers());
+ this.name = name + "-store";
+ this.joinedInternal = joinedInternal;
+ this.windows = windows;
+ this.loggingEnabled = joinedInternal.loggingEnabled();
+ this.logConfig = new HashMap<>(joinedInternal.logConfig());
+
+ // since this store is configured to retain duplicates, we should
+ // not compact, so we override the configuration to make sure that
+ // it's just delete (window stores are configured to compact,delete)
+ this.logConfig.put(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE);
Review Comment:
I guess it would be nice to have a test for this logic but honestly that could probably be saved for the followup work mentioned in that TODO which would be a more involved refactoring of the changelog topic configuration.
(Haven't gotten to the tests yet so maybe you already did this)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1396485217
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -529,14 +530,23 @@ public class StreamsConfig extends AbstractConfig {
private static final String DEFAULT_PRODUCTION_EXCEPTION_HANDLER_CLASS_DOC = "Exception handling class that implements the <code>org.apache.kafka.streams.errors.ProductionExceptionHandler</code> interface.";
/** {@code default.dsl.store} */
+ @Deprecated
@SuppressWarnings("WeakerAccess")
public static final String DEFAULT_DSL_STORE_CONFIG = "default.dsl.store";
+ @Deprecated
public static final String DEFAULT_DSL_STORE_DOC = "The default state store type used by DSL operators.";
+ @Deprecated
public static final String ROCKS_DB = "rocksDB";
+ @Deprecated
public static final String IN_MEMORY = "in_memory";
public static final String DEFAULT_DSL_STORE = ROCKS_DB;
Review Comment:
This should also be deprecated, right? (It's not used by the new config code I take it?)
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1394939779
##########
streams/src/main/java/org/apache/kafka/streams/TopologyConfig.java:
##########
@@ -216,12 +232,38 @@ public TopologyConfig(final String topologyName, final StreamsConfig globalAppCo
} else {
storeType = globalAppConfigs.getString(DEFAULT_DSL_STORE_CONFIG);
}
+
+ if (isTopologyOverride(DSL_STORE_SUPPLIERS_CLASS_CONFIG, topologyOverrides)) {
+ dslStoreSuppliers = getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ log.info("Topology {} is overriding {} to {}", topologyName, DSL_STORE_SUPPLIERS_CLASS_CONFIG, dslStoreSuppliers);
+ } else {
+ dslStoreSuppliers = globalAppConfigs.getString(DSL_STORE_SUPPLIERS_CLASS_CONFIG);
+ }
}
+ @Deprecated
public Materialized.StoreType parseStoreType() {
return MaterializedInternal.parse(storeType);
}
+ /**
+ * @return the DslStoreSuppliers if the value was explicitly configured (either by
+ * {@link StreamsConfig#DEFAULT_DSL_STORE} or {@link StreamsConfig#DSL_STORE_SUPPLIERS_CLASS_CONFIG})
+ */
+ public Optional<DslStoreSuppliers> resolveDslStoreSuppliers() {
Review Comment:
@ableegoldman - I'll add this back to the KIP, LMK if you think this API makes sense since it is technically public
##########
streams/src/main/java/org/apache/kafka/streams/state/BuiltinDslStoreSuppliers.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.state;
+
+import org.apache.kafka.streams.kstream.EmitStrategy;
+import org.apache.kafka.streams.state.internals.RocksDbIndexedTimeOrderedWindowBytesStoreSupplier;
+import org.apache.kafka.streams.state.internals.RocksDbTimeOrderedSessionBytesStoreSupplier;
+
+public class BuiltinDslStoreSuppliers {
+
+ public static final DslStoreSuppliers ROCKS_DB = new RocksDbDslStoreSuppliers();
+ public static final DslStoreSuppliers IN_MEMORY = new InMemoryDslStoreSuppliers();
+
+ public static class RocksDbDslStoreSuppliers implements DslStoreSuppliers {
Review Comment:
made the change, but FWIW it doesn't seem consistent throughout the code base

##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/MaterializedStoreFactory.java:
##########
@@ -16,42 +16,20 @@
*/
package org.apache.kafka.streams.kstream.internals;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
-import org.apache.kafka.streams.StreamsConfig;
-import org.apache.kafka.streams.kstream.Materialized;
import org.apache.kafka.streams.processor.StateStore;
import org.apache.kafka.streams.processor.internals.StoreFactory;
/**
* {@code MaterializedStoreFactory} is the base class for any {@link StoreFactory} that
* wraps a {@link MaterializedInternal} instance.
*/
-public abstract class MaterializedStoreFactory<K, V, S extends StateStore> implements StoreFactory {
+public abstract class MaterializedStoreFactory<K, V, S extends StateStore> extends AbstractConfigurableStoreFactory {
protected final MaterializedInternal<K, V, S> materialized;
- private final Set<String> connectedProcessorNames = new HashSet<>();
- protected Materialized.StoreType defaultStoreType
- = MaterializedInternal.parse(StreamsConfig.DEFAULT_DSL_STORE);
public MaterializedStoreFactory(final MaterializedInternal<K, V, S> materialized) {
+ super(materialized.dslStoreSuppliers().orElse(null));
this.materialized = materialized;
-
- // this condition will never be false; in the next PR we will
- // remove the initialization of storeType from MaterializedInternal
- if (materialized.storeType() != null) {
- defaultStoreType = materialized.storeType;
- }
- }
-
- @Override
- public void configure(final StreamsConfig config) {
- // in a follow-up PR, this will set the defaultStoreType to the configured value
Review Comment:
this PR does the follow-up in `AbstractConfiguredStoreFactory`
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamImplJoin.java:
##########
@@ -265,31 +261,6 @@ private void assertUniqueStoreNames(final WindowBytesStoreSupplier supplier,
}
}
- private static <K, V> StoreBuilder<WindowStore<K, V>> joinWindowStoreBuilder(final String storeName,
Review Comment:
All this deleted code was moved to their own StoreFactory implementations
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "agavra (via GitHub)" <gi...@apache.org>.
agavra commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1500157846
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
https://github.com/apache/kafka/pull/15424
--
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-15215: [KIP-954] support custom DSL store providers [kafka]
Posted by "ableegoldman (via GitHub)" <gi...@apache.org>.
ableegoldman commented on code in PR #14648:
URL: https://github.com/apache/kafka/pull/14648#discussion_r1500111316
##########
streams/streams-scala/src/test/scala/org/apache/kafka/streams/scala/kstream/StreamJoinedTest.scala:
##########
@@ -16,22 +16,36 @@
*/
package org.apache.kafka.streams.scala.kstream
-import org.apache.kafka.streams.kstream.internals.StreamJoinedInternal
+import org.apache.kafka.streams.kstream.internals.{InternalStreamsBuilder, StreamJoinedInternal}
+import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder
import org.apache.kafka.streams.scala.serialization.Serdes
import org.apache.kafka.streams.scala.serialization.Serdes._
import org.apache.kafka.streams.state.Stores
+import org.easymock.EasyMock
+import org.easymock.EasyMock.{createMock, replay}
import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.{BeforeEach, Test}
import java.time.Duration
class StreamJoinedTest {
+ val builder: InternalStreamsBuilder = createMock(classOf[InternalStreamsBuilder])
+ val topoBuilder: InternalTopologyBuilder = createMock(classOf[InternalTopologyBuilder])
+
+ @BeforeEach
+ def before(): Unit = {
+ EasyMock.expect(builder.internalTopologyBuilder()).andReturn(topoBuilder);
Review Comment:
Apologies, I should have caught this. I'm guessing Almog copied it from a java class that hadn't been converted yet, even though the scala test class was. Anyways thanks for the notice Ismael (Almog just ping me when you have a followup PR for this)
--
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