Search in sources :

Example 1 with DummyStreamsConfig

use of org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig in project kafka by apache.

the class TaskManagerTest method setUpTaskManager.

private void setUpTaskManager(final StreamsConfigUtils.ProcessingMode processingMode) {
    taskManager = new TaskManager(time, changeLogReader, UUID.randomUUID(), "taskManagerTest", new StreamsMetricsImpl(new Metrics(), "clientId", StreamsConfig.METRICS_LATEST, time), activeTaskCreator, standbyTaskCreator, new TopologyMetadata(topologyBuilder, new DummyStreamsConfig(processingMode)), adminClient, stateDirectory);
    taskManager.setMainConsumer(consumer);
    reset(topologyBuilder);
    expect(topologyBuilder.hasNamedTopology()).andStubReturn(false);
    activeTaskCreator.removeRevokedUnknownTasks(anyObject());
    expectLastCall().asStub();
    standbyTaskCreator.removeRevokedUnknownTasks(anyObject());
    expectLastCall().asStub();
}
Also used : Metrics(org.apache.kafka.common.metrics.Metrics) DummyStreamsConfig(org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig) StreamsMetricsImpl(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl)

Example 2 with DummyStreamsConfig

use of org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig in project kafka by apache.

the class StreamsMetadataStateTest method before.

@Before
public void before() {
    builder = new StreamsBuilder();
    final KStream<Object, Object> one = builder.stream("topic-one");
    one.groupByKey().count(Materialized.as("table-one"));
    final KStream<Object, Object> two = builder.stream("topic-two");
    two.groupByKey().count(Materialized.as("table-two"));
    builder.stream("topic-three").groupByKey().count(Materialized.as("table-three"));
    one.merge(two).groupByKey().count(Materialized.as("merged-table"));
    builder.stream("topic-four").mapValues(value -> value);
    builder.globalTable("global-topic", Consumed.with(null, null), Materialized.as(globalTable));
    TopologyWrapper.getInternalTopologyBuilder(builder.build()).setApplicationId("appId");
    topic1P0 = new TopicPartition("topic-one", 0);
    topic1P1 = new TopicPartition("topic-one", 1);
    topic2P0 = new TopicPartition("topic-two", 0);
    topic2P1 = new TopicPartition("topic-two", 1);
    topic3P0 = new TopicPartition("topic-three", 0);
    topic4P0 = new TopicPartition("topic-four", 0);
    hostOne = new HostInfo("host-one", 8080);
    hostTwo = new HostInfo("host-two", 9090);
    hostThree = new HostInfo("host-three", 7070);
    hostToActivePartitions = new HashMap<>();
    hostToActivePartitions.put(hostOne, mkSet(topic1P0, topic2P1, topic4P0));
    hostToActivePartitions.put(hostTwo, mkSet(topic2P0, topic1P1));
    hostToActivePartitions.put(hostThree, Collections.singleton(topic3P0));
    hostToStandbyPartitions = new HashMap<>();
    hostToStandbyPartitions.put(hostThree, mkSet(topic1P0, topic2P1, topic4P0));
    hostToStandbyPartitions.put(hostOne, mkSet(topic2P0, topic1P1));
    hostToStandbyPartitions.put(hostTwo, Collections.singleton(topic3P0));
    final List<PartitionInfo> partitionInfos = Arrays.asList(new PartitionInfo("topic-one", 0, null, null, null), new PartitionInfo("topic-one", 1, null, null, null), new PartitionInfo("topic-two", 0, null, null, null), new PartitionInfo("topic-two", 1, null, null, null), new PartitionInfo("topic-three", 0, null, null, null), new PartitionInfo("topic-four", 0, null, null, null));
    cluster = new Cluster(null, Collections.<Node>emptyList(), partitionInfos, Collections.<String>emptySet(), Collections.<String>emptySet());
    final TopologyMetadata topologyMetadata = new TopologyMetadata(TopologyWrapper.getInternalTopologyBuilder(builder.build()), new DummyStreamsConfig());
    topologyMetadata.buildAndRewriteTopology();
    metadataState = new StreamsMetadataState(topologyMetadata, hostOne, logContext);
    metadataState.onChange(hostToActivePartitions, hostToStandbyPartitions, cluster);
    partitioner = (topic, key, value, numPartitions) -> 1;
    storeNames = mkSet("table-one", "table-two", "merged-table", globalTable);
}
Also used : DummyStreamsConfig(org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig) Node(org.apache.kafka.common.Node) Cluster(org.apache.kafka.common.Cluster) StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) TopicPartition(org.apache.kafka.common.TopicPartition) PartitionInfo(org.apache.kafka.common.PartitionInfo) HostInfo(org.apache.kafka.streams.state.HostInfo) Before(org.junit.Before)

Example 3 with DummyStreamsConfig

use of org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig in project kafka by apache.

the class StreamsMetadataStateTest method shouldNotThrowExceptionWhenOnChangeNotCalled.

@Test
public void shouldNotThrowExceptionWhenOnChangeNotCalled() {
    final Collection<StreamsMetadata> metadata = new StreamsMetadataState(new TopologyMetadata(TopologyWrapper.getInternalTopologyBuilder(builder.build()), new DummyStreamsConfig()), hostOne, logContext).getAllMetadataForStore("store");
    assertEquals(0, metadata.size());
}
Also used : DummyStreamsConfig(org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig) StreamsMetadata(org.apache.kafka.streams.StreamsMetadata) Test(org.junit.Test)

Aggregations

DummyStreamsConfig (org.apache.kafka.streams.processor.internals.testutil.DummyStreamsConfig)3 Cluster (org.apache.kafka.common.Cluster)1 Node (org.apache.kafka.common.Node)1 PartitionInfo (org.apache.kafka.common.PartitionInfo)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)1 StreamsMetadata (org.apache.kafka.streams.StreamsMetadata)1 StreamsMetricsImpl (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl)1 HostInfo (org.apache.kafka.streams.state.HostInfo)1 Before (org.junit.Before)1 Test (org.junit.Test)1