Search in sources :

Example 1 with TopologyConfig

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

the class StreamTaskTest method createDisconnectedTask.

private StreamTask createDisconnectedTask(final StreamsConfig config) {
    final MockKeyValueStore stateStore = new MockKeyValueStore(storeName, false);
    final ProcessorTopology topology = ProcessorTopologyFactories.with(asList(source1, source2), mkMap(mkEntry(topic1, source1), mkEntry(topic2, source2)), singletonList(stateStore), emptyMap());
    final MockConsumer<byte[], byte[]> consumer = new MockConsumer<byte[], byte[]>(OffsetResetStrategy.EARLIEST) {

        @Override
        public Map<TopicPartition, OffsetAndMetadata> committed(final Set<TopicPartition> partitions) {
            throw new TimeoutException("KABOOM!");
        }
    };
    final InternalProcessorContext context = new ProcessorContextImpl(taskId, config, stateManager, streamsMetrics, null);
    return new StreamTask(taskId, partitions, topology, consumer, new TopologyConfig(null, config, new Properties()).getTaskConfig(), streamsMetrics, stateDirectory, cache, time, stateManager, recordCollector, context, logContext);
}
Also used : Utils.mkSet(org.apache.kafka.common.utils.Utils.mkSet) Set(java.util.Set) HashSet(java.util.HashSet) MockKeyValueStore(org.apache.kafka.test.MockKeyValueStore) Utils.mkProperties(org.apache.kafka.common.utils.Utils.mkProperties) Properties(java.util.Properties) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) MockConsumer(org.apache.kafka.clients.consumer.MockConsumer) TopologyConfig(org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig) TimeoutException(org.apache.kafka.common.errors.TimeoutException)

Example 2 with TopologyConfig

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

the class StreamTaskTest method createSingleSourceStateless.

private StreamTask createSingleSourceStateless(final StreamsConfig config, final String builtInMetricsVersion) {
    final ProcessorTopology topology = withSources(asList(source1, processorStreamTime, processorSystemTime), mkMap(mkEntry(topic1, source1)));
    source1.addChild(processorStreamTime);
    source1.addChild(processorSystemTime);
    EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
    EasyMock.expect(stateManager.changelogOffsets()).andReturn(Collections.emptyMap()).anyTimes();
    EasyMock.expect(recordCollector.offsets()).andReturn(Collections.emptyMap()).anyTimes();
    EasyMock.replay(stateManager, recordCollector);
    final InternalProcessorContext context = new ProcessorContextImpl(taskId, config, stateManager, streamsMetrics, null);
    return new StreamTask(taskId, mkSet(partition1), topology, consumer, new TopologyConfig(null, config, new Properties()).getTaskConfig(), new StreamsMetricsImpl(metrics, "test", builtInMetricsVersion, time), stateDirectory, cache, time, stateManager, recordCollector, context, logContext);
}
Also used : Utils.mkProperties(org.apache.kafka.common.utils.Utils.mkProperties) Properties(java.util.Properties) StreamsMetricsImpl(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl) TopologyConfig(org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig)

Example 3 with TopologyConfig

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

the class StreamTaskTest method createStatefulTask.

private StreamTask createStatefulTask(final StreamsConfig config, final boolean logged, final ProcessorStateManager stateManager) {
    final MockKeyValueStore stateStore = new MockKeyValueStore(storeName, logged);
    final ProcessorTopology topology = ProcessorTopologyFactories.with(asList(source1, source2), mkMap(mkEntry(topic1, source1), mkEntry(topic2, source2)), singletonList(stateStore), logged ? Collections.singletonMap(storeName, storeName + "-changelog") : Collections.emptyMap());
    final InternalProcessorContext context = new ProcessorContextImpl(taskId, config, stateManager, streamsMetrics, null);
    return new StreamTask(taskId, partitions, topology, consumer, new TopologyConfig(null, config, new Properties()).getTaskConfig(), streamsMetrics, stateDirectory, cache, time, stateManager, recordCollector, context, logContext);
}
Also used : MockKeyValueStore(org.apache.kafka.test.MockKeyValueStore) Utils.mkProperties(org.apache.kafka.common.utils.Utils.mkProperties) Properties(java.util.Properties) TopologyConfig(org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig)

Example 4 with TopologyConfig

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

the class StreamTaskTest method createFaultyStatefulTask.

private StreamTask createFaultyStatefulTask(final StreamsConfig config) {
    final ProcessorTopology topology = ProcessorTopologyFactories.with(asList(source1, source3), mkMap(mkEntry(topic1, source1), mkEntry(topic2, source3)), singletonList(stateStore), emptyMap());
    final InternalProcessorContext context = new ProcessorContextImpl(taskId, config, stateManager, streamsMetrics, null);
    return new StreamTask(taskId, partitions, topology, consumer, new TopologyConfig(null, config, new Properties()).getTaskConfig(), streamsMetrics, stateDirectory, cache, time, stateManager, recordCollector, context, logContext);
}
Also used : Utils.mkProperties(org.apache.kafka.common.utils.Utils.mkProperties) Properties(java.util.Properties) TopologyConfig(org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig)

Example 5 with TopologyConfig

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

the class StandbyTaskTest method createStandbyTask.

private StandbyTask createStandbyTask() {
    final ThreadCache cache = new ThreadCache(new LogContext(String.format("stream-thread [%s] ", Thread.currentThread().getName())), 0, streamsMetrics);
    final InternalProcessorContext context = new ProcessorContextImpl(taskId, config, stateManager, streamsMetrics, cache);
    return new StandbyTask(taskId, Collections.singleton(partition), topology, new TopologyConfig(config).getTaskConfig(), streamsMetrics, stateManager, stateDirectory, cache, context);
}
Also used : ThreadCache(org.apache.kafka.streams.state.internals.ThreadCache) LogContext(org.apache.kafka.common.utils.LogContext) TopologyConfig(org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig)

Aggregations

TopologyConfig (org.apache.kafka.streams.processor.internals.namedtopology.TopologyConfig)17 Properties (java.util.Properties)14 Utils.mkProperties (org.apache.kafka.common.utils.Utils.mkProperties)13 StreamsConfig (org.apache.kafka.streams.StreamsConfig)7 StreamsMetricsImpl (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl)5 Test (org.junit.Test)5 TopicPartition (org.apache.kafka.common.TopicPartition)4 LogContext (org.apache.kafka.common.utils.LogContext)3 MockKeyValueStore (org.apache.kafka.test.MockKeyValueStore)3 MockTime (org.apache.kafka.common.utils.MockTime)2 LogAndContinueExceptionHandler (org.apache.kafka.streams.errors.LogAndContinueExceptionHandler)2 TaskId (org.apache.kafka.streams.processor.TaskId)2 ThreadCache (org.apache.kafka.streams.state.internals.ThreadCache)2 MockTimestampExtractor (org.apache.kafka.test.MockTimestampExtractor)2 File (java.io.File)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 MockConsumer (org.apache.kafka.clients.consumer.MockConsumer)1 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)1 TimeoutException (org.apache.kafka.common.errors.TimeoutException)1