Search in sources :

Example 86 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.

the class StreamsBuilderTest method shouldUseSpecifiedNameForPrintOperation.

@Test
public void shouldUseSpecifiedNameForPrintOperation() {
    builder.stream(STREAM_TOPIC).print(Printed.toSysOut().withName("print-processor"));
    builder.build();
    final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
    assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", "print-processor");
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) Test(org.junit.Test)

Example 87 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.

the class StreamsBuilderTest method shouldUseSpecifiedNameForTransform.

@Test
public void shouldUseSpecifiedNameForTransform() {
    builder.stream(STREAM_TOPIC).transform(() -> null, Named.as(STREAM_OPERATION_NAME));
    builder.build();
    final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
    assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", STREAM_OPERATION_NAME);
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) Test(org.junit.Test)

Example 88 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.

the class StreamsBuilderTest method shouldUseSpecifiedNameForToStream.

@Test
public void shouldUseSpecifiedNameForToStream() {
    builder.table(STREAM_TOPIC).toStream(Named.as("to-stream"));
    builder.build();
    final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
    assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000001", "KTABLE-SOURCE-0000000002", "to-stream");
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) Test(org.junit.Test)

Example 89 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.

the class StreamsBuilderTest method shouldUseSpecifiedNameForAggregateOperationGivenTable.

@Test
public void shouldUseSpecifiedNameForAggregateOperationGivenTable() {
    builder.table(STREAM_TOPIC).groupBy(KeyValue::pair, Grouped.as("group-operation")).count(Named.as(STREAM_OPERATION_NAME));
    builder.build();
    final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
    assertNamesForStateStore(topology.stateStores(), STREAM_TOPIC + "-STATE-STORE-0000000000", "KTABLE-AGGREGATE-STATE-STORE-0000000004");
    assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000001", "KTABLE-SOURCE-0000000002", "group-operation", STREAM_OPERATION_NAME + "-sink", STREAM_OPERATION_NAME + "-source", STREAM_OPERATION_NAME);
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) Test(org.junit.Test)

Example 90 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.

the class StreamsBuilderTest method shouldAllowJoinUnmaterializedJoinedKTable.

@Test
public void shouldAllowJoinUnmaterializedJoinedKTable() {
    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), MockValueJoiner.TOSTRING_JOINER);
    builder.build();
    final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
    assertThat(topology.stateStores().size(), equalTo(2));
    assertThat(topology.processorConnectedStateStores("KSTREAM-JOIN-0000000010"), equalTo(Utils.mkSet(topology.stateStores().get(0).name(), topology.stateStores().get(1).name())));
    assertTrue(topology.processorConnectedStateStores("KTABLE-MERGE-0000000007").isEmpty());
}
Also used : Bytes(org.apache.kafka.common.utils.Bytes) ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) Test(org.junit.Test)

Aggregations

ProcessorTopology (org.apache.kafka.streams.processor.internals.ProcessorTopology)95 Test (org.junit.Test)89 Bytes (org.apache.kafka.common.utils.Bytes)17 MockTimestampExtractor (org.apache.kafka.test.MockTimestampExtractor)14 StateStore (org.apache.kafka.streams.processor.StateStore)13 StreamsConfig (org.apache.kafka.streams.StreamsConfig)10 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)8 FailOnInvalidTimestamp (org.apache.kafka.streams.processor.FailOnInvalidTimestamp)6 Pattern (java.util.regex.Pattern)5 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)5 HashSet (java.util.HashSet)4 Properties (java.util.Properties)4 Set (java.util.Set)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 List (java.util.List)3 KTable (org.apache.kafka.streams.kstream.KTable)3 InternalTopologyBuilder (org.apache.kafka.streams.processor.internals.InternalTopologyBuilder)3 SourceNode (org.apache.kafka.streams.processor.internals.SourceNode)3 Arrays.asList (java.util.Arrays.asList)2 Collections (java.util.Collections)2