use of org.apache.kafka.test.MockProcessorSupplier in project kafka by apache.
the class TopologyBuilderTest method shouldCorrectlyMapStateStoreToInternalTopics.
@Test
public void shouldCorrectlyMapStateStoreToInternalTopics() throws Exception {
final TopologyBuilder builder = new TopologyBuilder();
builder.setApplicationId("appId");
builder.addInternalTopic("internal-topic");
builder.addSource("source", "internal-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("appId-internal-topic"), stateStoreNameToSourceTopic.get("store"));
}
use of org.apache.kafka.test.MockProcessorSupplier in project kafka by apache.
the class TopologyBuilderTest method testAddProcessorWithSameName.
@Test(expected = TopologyBuilderException.class)
public void testAddProcessorWithSameName() {
final TopologyBuilder builder = new TopologyBuilder();
builder.addSource("source", "topic-1");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
}
use of org.apache.kafka.test.MockProcessorSupplier in project kafka by apache.
the class TopologyBuilderTest method testBuild.
@Test
public void testBuild() {
final TopologyBuilder builder = new TopologyBuilder();
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", "processor-1");
builder.addProcessor("processor-3", new MockProcessorSupplier(), "source-3", "source-4");
builder.setApplicationId("X");
ProcessorTopology topology0 = builder.build(0);
ProcessorTopology topology1 = builder.build(1);
ProcessorTopology topology2 = builder.build(2);
assertEquals(mkSet("source-1", "source-2", "processor-1", "processor-2"), nodeNames(topology0.processors()));
assertEquals(mkSet("source-3", "source-4", "processor-3"), nodeNames(topology1.processors()));
assertEquals(mkSet("source-5"), nodeNames(topology2.processors()));
}
use of org.apache.kafka.test.MockProcessorSupplier in project kafka by apache.
the class TopologyBuilderTest method shouldAssociateStateStoreNameWhenStateStoreSupplierIsExternal.
@Test
public void shouldAssociateStateStoreNameWhenStateStoreSupplierIsExternal() 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"));
}
use of org.apache.kafka.test.MockProcessorSupplier in project kafka by apache.
the class TopologyBuilderTest method shouldAddInternalTopicConfigWithCompactAndDeleteSetForWindowStores.
@SuppressWarnings("unchecked")
@Test
public void shouldAddInternalTopicConfigWithCompactAndDeleteSetForWindowStores() throws Exception {
final TopologyBuilder builder = new TopologyBuilder();
builder.setApplicationId("appId");
builder.addSource("source", "topic");
builder.addProcessor("processor", new MockProcessorSupplier(), "source");
builder.addStateStore(new RocksDBWindowStoreSupplier("store", 30000, 3, false, null, null, 10000, true, Collections.<String, String>emptyMap(), false), "processor");
final Map<Integer, TopicsInfo> topicGroups = builder.topicGroups();
final TopicsInfo topicsInfo = topicGroups.values().iterator().next();
final InternalTopicConfig topicConfig = topicsInfo.stateChangelogTopics.get("appId-store-changelog");
final Properties properties = topicConfig.toProperties(0);
final List<String> policies = Arrays.asList(properties.getProperty(InternalTopicManager.CLEANUP_POLICY_PROP).split(","));
assertEquals("appId-store-changelog", topicConfig.name());
assertTrue(policies.contains("compact"));
assertTrue(policies.contains("delete"));
assertEquals(2, policies.size());
assertEquals("30000", properties.getProperty(InternalTopicManager.RETENTION_MS));
assertEquals(2, properties.size());
}
Aggregations