Search in sources :

Example 6 with MockStateStoreSupplier

use of org.apache.kafka.test.MockStateStoreSupplier in project kafka by apache.

the class TopologyBuilderTest method testAddStateStoreWithDuplicates.

@Test(expected = TopologyBuilderException.class)
public void testAddStateStoreWithDuplicates() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addStateStore(new MockStateStoreSupplier("store", false));
    builder.addStateStore(new MockStateStoreSupplier("store", false));
}
Also used : MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) Test(org.junit.Test)

Example 7 with MockStateStoreSupplier

use of org.apache.kafka.test.MockStateStoreSupplier in project kafka by apache.

the class TopologyBuilderTest method testAddStateStoreWithSource.

@Test(expected = TopologyBuilderException.class)
public void testAddStateStoreWithSource() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource("source-1", "topic-1");
    builder.addStateStore(new MockStateStoreSupplier("store", false), "source-1");
}
Also used : MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) Test(org.junit.Test)

Example 8 with MockStateStoreSupplier

use of org.apache.kafka.test.MockStateStoreSupplier in project kafka by apache.

the class TopologyBuilderTest method testAddStateStoreWithNonExistingProcessor.

@Test(expected = TopologyBuilderException.class)
public void testAddStateStoreWithNonExistingProcessor() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addStateStore(new MockStateStoreSupplier("store", false), "no-such-processsor");
}
Also used : MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) Test(org.junit.Test)

Example 9 with MockStateStoreSupplier

use of org.apache.kafka.test.MockStateStoreSupplier in project kafka by apache.

the class TopologyBuilderTest method testTopicGroupsByStateStore.

@Test
public void testTopicGroupsByStateStore() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.setApplicationId("X");
    builder.addSource("source-1", "topic-1", "topic-1x");
    builder.addSource("source-2", "topic-2");
    builder.addSource("source-3", "topic-3");
    builder.addSource("source-4", "topic-4");
    builder.addSource("source-5", "topic-5");
    builder.addProcessor("processor-1", new MockProcessorSupplier(), "source-1");
    builder.addProcessor("processor-2", new MockProcessorSupplier(), "source-2");
    builder.addStateStore(new MockStateStoreSupplier("store-1", false), "processor-1", "processor-2");
    builder.addProcessor("processor-3", new MockProcessorSupplier(), "source-3");
    builder.addProcessor("processor-4", new MockProcessorSupplier(), "source-4");
    builder.addStateStore(new MockStateStoreSupplier("store-2", false), "processor-3", "processor-4");
    builder.addProcessor("processor-5", new MockProcessorSupplier(), "source-5");
    StateStoreSupplier supplier = new MockStateStoreSupplier("store-3", false);
    builder.addStateStore(supplier);
    builder.connectProcessorAndStateStores("processor-5", "store-3");
    Map<Integer, TopicsInfo> topicGroups = builder.topicGroups();
    Map<Integer, TopicsInfo> expectedTopicGroups = new HashMap<>();
    final String store1 = ProcessorStateManager.storeChangelogTopic("X", "store-1");
    final String store2 = ProcessorStateManager.storeChangelogTopic("X", "store-2");
    final String store3 = ProcessorStateManager.storeChangelogTopic("X", "store-3");
    expectedTopicGroups.put(0, new TopicsInfo(Collections.<String>emptySet(), mkSet("topic-1", "topic-1x", "topic-2"), Collections.<String, InternalTopicConfig>emptyMap(), Collections.singletonMap(store1, new InternalTopicConfig(store1, Collections.singleton(InternalTopicConfig.CleanupPolicy.compact), Collections.<String, String>emptyMap()))));
    expectedTopicGroups.put(1, new TopicsInfo(Collections.<String>emptySet(), mkSet("topic-3", "topic-4"), Collections.<String, InternalTopicConfig>emptyMap(), Collections.singletonMap(store2, new InternalTopicConfig(store2, Collections.singleton(InternalTopicConfig.CleanupPolicy.compact), Collections.<String, String>emptyMap()))));
    expectedTopicGroups.put(2, new TopicsInfo(Collections.<String>emptySet(), mkSet("topic-5"), Collections.<String, InternalTopicConfig>emptyMap(), Collections.singletonMap(store3, new InternalTopicConfig(store3, Collections.singleton(InternalTopicConfig.CleanupPolicy.compact), Collections.<String, String>emptyMap()))));
    assertEquals(3, topicGroups.size());
    assertEquals(expectedTopicGroups, topicGroups);
}
Also used : MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) HashMap(java.util.HashMap) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) InternalTopicConfig(org.apache.kafka.streams.processor.internals.InternalTopicConfig) TopicsInfo(org.apache.kafka.streams.processor.TopologyBuilder.TopicsInfo) Test(org.junit.Test)

Example 10 with MockStateStoreSupplier

use of org.apache.kafka.test.MockStateStoreSupplier in project kafka by apache.

the class TopologyBuilderTest method shouldAssociateStateStoreNameWhenStateStoreSupplierIsInternal.

@Test
public void shouldAssociateStateStoreNameWhenStateStoreSupplierIsInternal() throws Exception {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.addSource("source", "topic");
    builder.addProcessor("processor", new MockProcessorSupplier(), "source");
    builder.addStateStore(new MockStateStoreSupplier("store", false), "processor");
    final Map<String, List<String>> stateStoreNameToSourceTopic = builder.stateStoreNameToSourceTopics();
    assertEquals(1, stateStoreNameToSourceTopic.size());
    assertEquals(Collections.singletonList("topic"), stateStoreNameToSourceTopic.get("store"));
}
Also used : MockProcessorSupplier(org.apache.kafka.test.MockProcessorSupplier) Utils.mkList(org.apache.kafka.common.utils.Utils.mkList) List(java.util.List) MockStateStoreSupplier(org.apache.kafka.test.MockStateStoreSupplier) Test(org.junit.Test)

Aggregations

MockStateStoreSupplier (org.apache.kafka.test.MockStateStoreSupplier)13 Test (org.junit.Test)13 MockProcessorSupplier (org.apache.kafka.test.MockProcessorSupplier)8 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Metrics (org.apache.kafka.common.metrics.Metrics)3 Utils.mkList (org.apache.kafka.common.utils.Utils.mkList)3 TaskId (org.apache.kafka.streams.processor.TaskId)3 Properties (java.util.Properties)2 UUID (java.util.UUID)2 PartitionAssignor (org.apache.kafka.clients.consumer.internals.PartitionAssignor)2 StreamsConfig (org.apache.kafka.streams.StreamsConfig)2 TopicsInfo (org.apache.kafka.streams.processor.TopologyBuilder.TopicsInfo)2 InternalTopicConfig (org.apache.kafka.streams.processor.internals.InternalTopicConfig)2 AssignmentInfo (org.apache.kafka.streams.processor.internals.assignment.AssignmentInfo)2 SubscriptionInfo (org.apache.kafka.streams.processor.internals.assignment.SubscriptionInfo)2 MockInternalTopicManager (org.apache.kafka.test.MockInternalTopicManager)2 Collection (java.util.Collection)1 Set (java.util.Set)1