use of org.apache.kafka.streams.processor.StateStoreSupplier in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopologyBuilderTest method testAddStateStore.
@SuppressWarnings("deprecation")
@Test
public void testAddStateStore() {
final StateStoreSupplier supplier = new MockStateStoreSupplier("store-1", false);
builder.addStateStore(supplier);
builder.setApplicationId("X");
builder.addSource(null, "source-1", null, null, null, "topic-1");
builder.addProcessor("processor-1", new MockProcessorSupplier(), "source-1");
assertEquals(0, builder.build(null).stateStores().size());
builder.connectProcessorAndStateStores("processor-1", "store-1");
final List<StateStore> suppliers = builder.build(null).stateStores();
assertEquals(1, suppliers.size());
assertEquals(supplier.name(), suppliers.get(0).name());
}
use of org.apache.kafka.streams.processor.StateStoreSupplier in project apache-kafka-on-k8s by banzaicloud.
the class StoresTest method shouldCreateInMemoryStoreSupplierNotLogged.
@SuppressWarnings("deprecation")
@Test
public void shouldCreateInMemoryStoreSupplierNotLogged() {
final StateStoreSupplier supplier = Stores.create("store").withKeys(Serdes.String()).withValues(Serdes.String()).inMemory().disableLogging().build();
assertFalse(supplier.loggingEnabled());
}
use of org.apache.kafka.streams.processor.StateStoreSupplier in project apache-kafka-on-k8s by banzaicloud.
the class StoresTest method shouldCreateInMemoryStoreSupplierWithLoggedConfig.
@SuppressWarnings("deprecation")
@Test
public void shouldCreateInMemoryStoreSupplierWithLoggedConfig() {
final StateStoreSupplier supplier = Stores.create("store").withKeys(Serdes.String()).withValues(Serdes.String()).inMemory().enableLogging(Collections.singletonMap("retention.ms", "1000")).build();
final Map<String, String> config = supplier.logConfig();
assertTrue(supplier.loggingEnabled());
assertEquals("1000", config.get("retention.ms"));
}
use of org.apache.kafka.streams.processor.StateStoreSupplier in project apache-kafka-on-k8s by banzaicloud.
the class StoresTest method shouldCreatePersistenStoreSupplierWithLoggedConfig.
@SuppressWarnings("deprecation")
@Test
public void shouldCreatePersistenStoreSupplierWithLoggedConfig() {
final StateStoreSupplier supplier = Stores.create("store").withKeys(Serdes.String()).withValues(Serdes.String()).persistent().enableLogging(Collections.singletonMap("retention.ms", "1000")).build();
final Map<String, String> config = supplier.logConfig();
assertTrue(supplier.loggingEnabled());
assertEquals("1000", config.get("retention.ms"));
}
use of org.apache.kafka.streams.processor.StateStoreSupplier in project apache-kafka-on-k8s by banzaicloud.
the class ProcessorTopologyTest method shouldDriveGlobalStore.
@SuppressWarnings("unchecked")
@Test
public void shouldDriveGlobalStore() {
final String storeName = "my-store";
final StateStoreSupplier storeSupplier = Stores.create(storeName).withStringKeys().withStringValues().inMemory().disableLogging().build();
final String global = "global";
final String topic = "topic";
final TopologyBuilder topologyBuilder = this.builder.addGlobalStore(storeSupplier, global, STRING_DESERIALIZER, STRING_DESERIALIZER, topic, "processor", define(new StatefulProcessor(storeName)));
driver = new ProcessorTopologyTestDriver(config, topologyBuilder.internalTopologyBuilder);
final KeyValueStore<String, String> globalStore = (KeyValueStore<String, String>) topologyBuilder.globalStateStores().get(storeName);
driver.process(topic, "key1", "value1", STRING_SERIALIZER, STRING_SERIALIZER);
driver.process(topic, "key2", "value2", STRING_SERIALIZER, STRING_SERIALIZER);
assertEquals("value1", globalStore.get("key1"));
assertEquals("value2", globalStore.get("key2"));
}
Aggregations