use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldUseGeneratedNameForJoinOperationBetweenKStreamAndKStream.
@SuppressWarnings("deprecation")
@Test
public void shouldUseGeneratedNameForJoinOperationBetweenKStreamAndKStream() {
final KStream<String, String> streamOne = builder.stream(STREAM_TOPIC);
final KStream<String, String> streamTwo = builder.stream(STREAM_TOPIC_TWO);
streamOne.join(streamTwo, (value1, value2) -> value1, JoinWindows.of(Duration.ofHours(1)), StreamJoined.with(Serdes.String(), Serdes.String(), Serdes.String()).withName(STREAM_OPERATION_NAME));
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertNamesForStateStore(topology.stateStores(), "KSTREAM-JOINTHIS-0000000004-store", "KSTREAM-JOINOTHER-0000000005-store");
assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", "KSTREAM-SOURCE-0000000001", STREAM_OPERATION_NAME + "-this-windowed", STREAM_OPERATION_NAME + "-other-windowed", STREAM_OPERATION_NAME + "-this-join", STREAM_OPERATION_NAME + "-other-join", STREAM_OPERATION_NAME + "-merge");
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldUseSpecifiedNameForTableSourceProcessor.
@Test
public void shouldUseSpecifiedNameForTableSourceProcessor() {
final String expected = "source-node";
builder.table(STREAM_TOPIC, Consumed.as(expected));
builder.table(STREAM_TOPIC_TWO);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertNamesForOperation(topology, expected + "-source", expected, "KSTREAM-SOURCE-0000000004", "KTABLE-SOURCE-0000000005");
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldAllowJoinMaterializedJoinedKTable.
@Test
public void shouldAllowJoinMaterializedJoinedKTable() {
final KTable<Bytes, String> table1 = builder.table("table-topic1");
final KTable<Bytes, String> table2 = builder.table("table-topic2");
builder.<Bytes, String>stream(STREAM_TOPIC).join(table1.join(table2, MockValueJoiner.TOSTRING_JOINER, Materialized.as("store")), MockValueJoiner.TOSTRING_JOINER);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertThat(topology.stateStores().size(), equalTo(3));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000010"), equalTo(Collections.singleton("store")));
assertThat(topology.processorConnectedStateStores("KTABLE-MERGE-0000000007"), equalTo(Collections.singleton("store")));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldAllowJoinMaterializedSourceKTable.
@Test
public void shouldAllowJoinMaterializedSourceKTable() {
final KTable<Bytes, String> table = builder.table(TABLE_TOPIC);
builder.<Bytes, String>stream(STREAM_TOPIC).join(table, MockValueJoiner.TOSTRING_JOINER);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertThat(topology.stateStores().size(), equalTo(1));
assertThat(topology.processorConnectedStateStores("KTABLE-SOURCE-0000000002"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000004"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldAllowJoinUnmaterializedMapValuedKTable.
@Test
public void shouldAllowJoinUnmaterializedMapValuedKTable() {
final KTable<Bytes, String> mappedKTable = builder.<Bytes, String>table(TABLE_TOPIC).mapValues(MockMapper.noOpValueMapper());
builder.<Bytes, String>stream(STREAM_TOPIC).join(mappedKTable, MockValueJoiner.TOSTRING_JOINER);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertThat(topology.stateStores().size(), equalTo(1));
assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000005"), equalTo(Collections.singleton(topology.stateStores().get(0).name())));
assertTrue(topology.processorConnectedStateStores("KTABLE-MAPVALUES-0000000003").isEmpty());
}
Aggregations