use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class KStreamImplTest method shouldUseRecordMetadataTimestampExtractorWithThrough.
@Deprecated
@Test
public void shouldUseRecordMetadataTimestampExtractorWithThrough() {
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.through("topic-6");
final ProcessorTopology processorTopology = TopologyWrapper.getInternalTopologyBuilder(builder.build()).setApplicationId("X").buildTopology();
assertThat(processorTopology.source("topic-6").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 KStreamImplTest method shouldUseRecordMetadataTimestampExtractorWhenInternalRepartitioningTopicCreatedWithRetention.
@SuppressWarnings("deprecation")
@Test
public void shouldUseRecordMetadataTimestampExtractorWhenInternalRepartitioningTopicCreatedWithRetention() {
final StreamsBuilder builder = new StreamsBuilder();
final KStream<String, String> kStream = builder.stream("topic-1", stringConsumed);
final ValueJoiner<String, String, String> valueJoiner = MockValueJoiner.instance(":");
final long windowSize = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
final KStream<String, String> stream = kStream.map((key, value) -> KeyValue.pair(value, value));
stream.join(kStream, valueJoiner, JoinWindows.of(ofMillis(windowSize)).grace(ofMillis(3 * windowSize)), StreamJoined.with(Serdes.String(), Serdes.String(), Serdes.String())).to("output-topic", Produced.with(Serdes.String(), Serdes.String()));
final ProcessorTopology topology = TopologyWrapper.getInternalTopologyBuilder(builder.build()).setApplicationId("X").buildTopology();
final SourceNode<?, ?> originalSourceNode = topology.source("topic-1");
for (final SourceNode<?, ?> sourceNode : topology.sources()) {
if (sourceNode.name().equals(originalSourceNode.name())) {
assertNull(sourceNode.getTimestampExtractor());
} else {
assertThat(sourceNode.getTimestampExtractor(), instanceOf(FailOnInvalidTimestamp.class));
}
}
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class InternalStreamsBuilderTest method doBuildGlobalTopologyWithAllGlobalTables.
private void doBuildGlobalTopologyWithAllGlobalTables() {
final ProcessorTopology topology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID))).buildGlobalStateTopology();
final List<StateStore> stateStores = topology.globalStateStores();
final Set<String> sourceTopics = topology.sourceTopics();
assertEquals(Utils.mkSet("table", "table2"), sourceTopics);
assertEquals(2, stateStores.size());
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class InternalStreamsBuilderTest method shouldUseProvidedTimestampExtractor.
@Test
public void shouldUseProvidedTimestampExtractor() {
final ConsumedInternal<String, String> consumed = new ConsumedInternal<>(Consumed.with(new MockTimestampExtractor()));
builder.stream(Collections.singleton("topic"), consumed);
builder.buildAndOptimizeTopology();
final ProcessorTopology processorTopology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID))).buildTopology();
assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
use of org.apache.kafka.streams.processor.internals.ProcessorTopology in project kafka by apache.
the class InternalStreamsBuilderTest method ktableShouldUseProvidedTimestampExtractor.
@Test
public void ktableShouldUseProvidedTimestampExtractor() {
final ConsumedInternal<String, String> consumed = new ConsumedInternal<>(Consumed.with(new MockTimestampExtractor()));
builder.table("topic", consumed, materialized);
builder.buildAndOptimizeTopology();
final ProcessorTopology processorTopology = builder.internalTopologyBuilder.rewriteTopology(new StreamsConfig(StreamsTestUtils.getStreamsConfig(APP_ID))).buildTopology();
assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class));
}
Aggregations