use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class KStreamImplTest method shouldUseRecordMetadataTimestampExtractorWithRepartition.
@Test
public void shouldUseRecordMetadataTimestampExtractorWithRepartition() {
final StreamsBuilder builder = new StreamsBuilder();
final KStream<String, String> stream1 = builder.stream(Arrays.asList("topic-1", "topic-2"), stringConsumed);
final KStream<String, String> stream2 = builder.stream(Arrays.asList("topic-3", "topic-4"), stringConsumed);
stream1.to("topic-5");
stream2.repartition(Repartitioned.as("topic-6"));
final ProcessorTopology processorTopology = TopologyWrapper.getInternalTopologyBuilder(builder.build()).setApplicationId("X").buildTopology();
assertThat(processorTopology.source("X-topic-6-repartition").getTimestampExtractor(), instanceOf(FailOnInvalidTimestamp.class));
assertNull(processorTopology.source("topic-4").getTimestampExtractor());
assertNull(processorTopology.source("topic-3").getTimestampExtractor());
assertNull(processorTopology.source("topic-2").getTimestampExtractor());
assertNull(processorTopology.source("topic-1").getTimestampExtractor());
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class InternalStreamsBuilderTest method shouldNotMaterializeSourceKTableIfNotRequired.
@Test
public void shouldNotMaterializeSourceKTableIfNotRequired() {
final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materializedInternal = new MaterializedInternal<>(Materialized.with(null, null), builder, storePrefix);
final KTable<String, String> table1 = builder.table("topic2", consumed, materializedInternal);
builder.buildAndOptimizeTopology();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID))).buildTopology();
assertEquals(0, topology.stateStores().size());
assertEquals(0, topology.storeToChangelogTopic().size());
assertNull(table1.queryableStoreName());
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class InternalStreamsBuilderTest method shouldHaveNullTimestampExtractorWhenNoneSupplied.
@Test
public void shouldHaveNullTimestampExtractorWhenNoneSupplied() {
builder.stream(Collections.singleton("topic"), consumed);
builder.buildAndOptimizeTopology();
builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID)));
final ProcessorTopology processorTopology = builder.internalTopologyBuilder.buildTopology();
assertNull(processorTopology.source("topic").getTimestampExtractor());
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldUseSpecifiedNameForSinkProcessor.
@Test
public void shouldUseSpecifiedNameForSinkProcessor() {
final String expected = "sink-processor";
final KStream<Object, Object> stream = builder.stream(STREAM_TOPIC);
stream.to(STREAM_TOPIC_TWO, Produced.as(expected));
stream.to(STREAM_TOPIC_TWO);
builder.build();
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertNamesForOperation(topology, "KSTREAM-SOURCE-0000000000", expected, "KSTREAM-SINK-0000000002");
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class StreamsBuilderTest method shouldNotMaterializeStoresIfNotRequired.
@Test
public void shouldNotMaterializeStoresIfNotRequired() {
final String topic = "topic";
builder.table(topic, Materialized.with(Serdes.Long(), Serdes.String()));
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(props)).buildTopology();
assertThat(topology.stateStores().size(), equalTo(0));
}
Aggregations