Search in sources :

Example 21 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorWithOffsetResetAndPatternPerSource.

@Test
public void shouldAddTimestampExtractorWithOffsetResetAndPatternPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    final Pattern pattern = Pattern.compile("t.*");
    builder.addSource(null, new MockTimestampExtractor(), "source", pattern);
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source(pattern.pattern()).getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : Pattern(java.util.regex.Pattern) ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 22 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorWithOffsetResetAndKeyValSerdesPerSource.

@Test
public void shouldAddTimestampExtractorWithOffsetResetAndKeyValSerdesPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource(null, "source", new MockTimestampExtractor(), null, null, "topic");
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 23 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method testBuild.

@Test
public void testBuild() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource("source-1", "topic-1", "topic-1x");
    builder.addSource("source-2", "topic-2");
    builder.addSource("source-3", "topic-3");
    builder.addSource("source-4", "topic-4");
    builder.addSource("source-5", "topic-5");
    builder.addProcessor("processor-1", new MockProcessorSupplier(), "source-1");
    builder.addProcessor("processor-2", new MockProcessorSupplier(), "source-2", "processor-1");
    builder.addProcessor("processor-3", new MockProcessorSupplier(), "source-3", "source-4");
    builder.setApplicationId("X");
    ProcessorTopology topology0 = builder.build(0);
    ProcessorTopology topology1 = builder.build(1);
    ProcessorTopology topology2 = builder.build(2);
    assertEquals(mkSet("source-1", "source-2", "processor-1", "processor-2"), nodeNames(topology0.processors()));
    assertEquals(mkSet("source-3", "source-4", "processor-3"), nodeNames(topology1.processors()));
    assertEquals(mkSet("source-5"), nodeNames(topology2.processors()));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) Test(org.junit.Test)

Example 24 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorWithOffsetResetPerSource.

@Test
public void shouldAddTimestampExtractorWithOffsetResetPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource(null, new MockTimestampExtractor(), "source", "topic");
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) Test(org.junit.Test)

Example 25 with ProcessorTopology

use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project apache-kafka-on-k8s by banzaicloud.

the class TopologyBuilderTest method shouldAddTimestampExtractorWithOffsetResetAndKeyValSerdesAndPatternPerSource.

@Test
public void shouldAddTimestampExtractorWithOffsetResetAndKeyValSerdesAndPatternPerSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    final Pattern pattern = Pattern.compile("t.*");
    builder.addSource(null, "source", new MockTimestampExtractor(), null, null, pattern);
    final ProcessorTopology processorTopology = builder.build(null);
    assertThat(processorTopology.source(pattern.pattern()).getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Also used : Pattern(java.util.regex.Pattern) ProcessorTopology(org.apache.kafka.streams.processor.internals.ProcessorTopology) MockTimestampExtractor(org.apache.kafka.test.MockTimestampExtractor) 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