use of org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig in project kafka by apache.
the class InternalTopologyBuilderTest method shouldOverrideGlobalStreamsConfigWhenGivenNamedTopologyProps.
@Test
public void shouldOverrideGlobalStreamsConfigWhenGivenNamedTopologyProps() {
final Properties topologyOverrides = new Properties();
topologyOverrides.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 12345L);
topologyOverrides.put(StreamsConfig.MAX_TASK_IDLE_MS_CONFIG, 500L);
topologyOverrides.put(StreamsConfig.TASK_TIMEOUT_MS_CONFIG, 1000L);
topologyOverrides.put(StreamsConfig.BUFFERED_RECORDS_PER_PARTITION_CONFIG, 15);
topologyOverrides.put(StreamsConfig.DEFAULT_TIMESTAMP_EXTRACTOR_CLASS_CONFIG, MockTimestampExtractor.class);
topologyOverrides.put(StreamsConfig.DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG, LogAndContinueExceptionHandler.class);
final StreamsConfig config = new StreamsConfig(StreamsTestUtils.getStreamsConfig());
final InternalTopologyBuilder topologyBuilder = new InternalTopologyBuilder(new TopologyConfig("my-topology", config, topologyOverrides));
assertThat(topologyBuilder.topologyConfigs().cacheSize, is(12345L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().maxTaskIdleMs, equalTo(500L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().taskTimeoutMs, equalTo(1000L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().maxBufferedSize, equalTo(15));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().timestampExtractor.getClass(), equalTo(MockTimestampExtractor.class));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().deserializationExceptionHandler.getClass(), equalTo(LogAndContinueExceptionHandler.class));
}
use of org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig in project kafka by apache.
the class InternalTopologyBuilderTest method shouldNotOverrideGlobalStreamsConfigWhenGivenUnnamedTopologyProps.
@Test
public void shouldNotOverrideGlobalStreamsConfigWhenGivenUnnamedTopologyProps() {
final Properties streamsProps = StreamsTestUtils.getStreamsConfig();
streamsProps.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 12345L);
streamsProps.put(StreamsConfig.MAX_TASK_IDLE_MS_CONFIG, 500L);
streamsProps.put(StreamsConfig.TASK_TIMEOUT_MS_CONFIG, 1000L);
streamsProps.put(StreamsConfig.BUFFERED_RECORDS_PER_PARTITION_CONFIG, 15);
streamsProps.put(StreamsConfig.DEFAULT_TIMESTAMP_EXTRACTOR_CLASS_CONFIG, MockTimestampExtractor.class);
streamsProps.put(StreamsConfig.DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG, LogAndContinueExceptionHandler.class);
final StreamsConfig config = new StreamsConfig(streamsProps);
final InternalTopologyBuilder topologyBuilder = new InternalTopologyBuilder(new TopologyConfig("my-topology", config, new Properties()));
assertThat(topologyBuilder.topologyConfigs().cacheSize, is(12345L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().maxTaskIdleMs, is(500L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().taskTimeoutMs, is(1000L));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().maxBufferedSize, is(15));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().timestampExtractor.getClass(), is(MockTimestampExtractor.class));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().deserializationExceptionHandler.getClass(), is(LogAndContinueExceptionHandler.class));
}
use of org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig in project kafka by apache.
the class InternalTopologyBuilder method setStreamsConfig.
public final synchronized void setStreamsConfig(final StreamsConfig applicationConfig) {
Objects.requireNonNull(applicationConfig, "config can't be null");
topologyConfigs = new TopologyConfig(applicationConfig);
}
use of org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig in project kafka by apache.
the class InternalTopologyBuilderTest method shouldSetTopologyConfigOnRewriteTopology.
@Test
public void shouldSetTopologyConfigOnRewriteTopology() {
final Properties globalProps = StreamsTestUtils.getStreamsConfig();
globalProps.put(StreamsConfig.MAX_TASK_IDLE_MS_CONFIG, 100L);
final StreamsConfig globalStreamsConfig = new StreamsConfig(globalProps);
final InternalTopologyBuilder topologyBuilder = builder.rewriteTopology(globalStreamsConfig);
assertThat(topologyBuilder.topologyConfigs(), equalTo(new TopologyConfig(null, globalStreamsConfig, new Properties())));
assertThat(topologyBuilder.topologyConfigs().getTaskConfig().maxTaskIdleMs, equalTo(100L));
}
use of org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig in project kafka by apache.
the class ActiveTaskCreatorTest method createTasks.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void createTasks() {
final TaskId task00 = new TaskId(0, 0);
final TaskId task01 = new TaskId(0, 1);
final ProcessorTopology topology = mock(ProcessorTopology.class);
final SourceNode sourceNode = mock(SourceNode.class);
reset(builder, stateDirectory);
expect(builder.topologyConfigs()).andStubReturn(new TopologyConfig(new StreamsConfig(properties)));
expect(builder.buildSubtopology(0)).andReturn(topology).anyTimes();
expect(stateDirectory.getOrCreateDirectoryForTask(task00)).andReturn(mock(File.class));
expect(stateDirectory.checkpointFileFor(task00)).andReturn(mock(File.class));
expect(stateDirectory.getOrCreateDirectoryForTask(task01)).andReturn(mock(File.class));
expect(stateDirectory.checkpointFileFor(task01)).andReturn(mock(File.class));
expect(topology.storeToChangelogTopic()).andReturn(Collections.emptyMap()).anyTimes();
expect(topology.source("topic")).andReturn(sourceNode).anyTimes();
expect(sourceNode.getTimestampExtractor()).andReturn(mock(TimestampExtractor.class)).anyTimes();
expect(topology.globalStateStores()).andReturn(Collections.emptyList()).anyTimes();
expect(topology.terminalNodes()).andStubReturn(Collections.singleton(sourceNode.name()));
expect(topology.sources()).andStubReturn(Collections.singleton(sourceNode));
replay(builder, stateDirectory, topology, sourceNode);
final StreamsConfig config = new StreamsConfig(properties);
activeTaskCreator = new ActiveTaskCreator(new TopologyMetadata(builder, config), config, streamsMetrics, stateDirectory, changeLogReader, new ThreadCache(new LogContext(), 0L, streamsMetrics), new MockTime(), mockClientSupplier, "clientId-StreamThread-0", uuid, new LogContext().logger(ActiveTaskCreator.class));
assertThat(activeTaskCreator.createTasks(mockClientSupplier.consumer, mkMap(mkEntry(task00, Collections.singleton(new TopicPartition("topic", 0))), mkEntry(task01, Collections.singleton(new TopicPartition("topic", 1))))).stream().map(Task::id).collect(Collectors.toSet()), equalTo(mkSet(task00, task01)));
}
Aggregations