use of org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer in project apache-kafka-on-k8s by banzaicloud.
the class KeyValueStoreMaterializerTest method shouldCreateBuilderThatBuildsStoreWithLoggingDisabled.
@Test
public void shouldCreateBuilderThatBuildsStoreWithLoggingDisabled() {
final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<String, String, KeyValueStore<Bytes, byte[]>>as("store").withLoggingDisabled(), nameProvider, storePrefix);
final KeyValueStoreMaterializer<String, String> materializer = new KeyValueStoreMaterializer<>(materialized);
final StoreBuilder<KeyValueStore<String, String>> builder = materializer.materialize();
final KeyValueStore<String, String> store = builder.build();
final WrappedStateStore caching = (WrappedStateStore) ((WrappedStateStore) store).wrappedStore();
assertThat(caching, instanceOf(CachedStateStore.class));
assertThat(caching.wrappedStore(), not(instanceOf(ChangeLoggingKeyValueBytesStore.class)));
}
use of org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer in project apache-kafka-on-k8s by banzaicloud.
the class KeyValueStoreMaterializerTest method shouldCreateKeyValueStoreWithTheProvidedInnerStore.
@Test
public void shouldCreateKeyValueStoreWithTheProvidedInnerStore() {
final KeyValueBytesStoreSupplier supplier = EasyMock.createNiceMock(KeyValueBytesStoreSupplier.class);
final InMemoryKeyValueStore<Bytes, byte[]> store = new InMemoryKeyValueStore<>("name", Serdes.Bytes(), Serdes.ByteArray());
EasyMock.expect(supplier.name()).andReturn("name").anyTimes();
EasyMock.expect(supplier.get()).andReturn(store);
EasyMock.replay(supplier);
final MaterializedInternal<String, Integer, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<String, Integer>as(supplier), nameProvider, storePrefix);
final KeyValueStoreMaterializer<String, Integer> materializer = new KeyValueStoreMaterializer<>(materialized);
final StoreBuilder<KeyValueStore<String, Integer>> builder = materializer.materialize();
final KeyValueStore<String, Integer> built = builder.build();
final StateStore inner = ((WrappedStateStore) built).inner();
assertThat(inner, CoreMatchers.<StateStore>equalTo(store));
}
use of org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer in project apache-kafka-on-k8s by banzaicloud.
the class GlobalStreamThreadTest method before.
@SuppressWarnings("unchecked")
@Before
public void before() {
final MaterializedInternal<Object, Object, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<Object, Object, KeyValueStore<Bytes, byte[]>>with(null, null), new InternalNameProvider() {
@Override
public String newProcessorName(String prefix) {
return "processorName";
}
@Override
public String newStoreName(String prefix) {
return GLOBAL_STORE_NAME;
}
}, "store-");
builder.addGlobalStore((StoreBuilder) new KeyValueStoreMaterializer<>(materialized).materialize().withLoggingDisabled(), "sourceName", null, null, null, GLOBAL_STORE_TOPIC_NAME, "processorName", new KTableSource<>(GLOBAL_STORE_NAME));
final HashMap<String, Object> properties = new HashMap<>();
properties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "blah");
properties.put(StreamsConfig.APPLICATION_ID_CONFIG, "blah");
properties.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getAbsolutePath());
config = new StreamsConfig(properties);
globalStreamThread = new GlobalStreamThread(builder.buildGlobalStateTopology(), config, mockConsumer, new StateDirectory(config, time), 0, new Metrics(), new MockTime(), "clientId", stateRestoreListener);
}
use of org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer in project apache-kafka-on-k8s by banzaicloud.
the class KeyValueStoreMaterializerTest method shouldCreateBuilderThatBuildsStoreWithCachingDisabled.
@Test
public void shouldCreateBuilderThatBuildsStoreWithCachingDisabled() {
final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<String, String, KeyValueStore<Bytes, byte[]>>as("store").withCachingDisabled(), nameProvider, storePrefix);
final KeyValueStoreMaterializer<String, String> materializer = new KeyValueStoreMaterializer<>(materialized);
final StoreBuilder<KeyValueStore<String, String>> builder = materializer.materialize();
final KeyValueStore<String, String> store = builder.build();
final WrappedStateStore logging = (WrappedStateStore) ((WrappedStateStore) store).wrappedStore();
assertThat(logging, instanceOf(ChangeLoggingKeyValueBytesStore.class));
}
use of org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer in project apache-kafka-on-k8s by banzaicloud.
the class KeyValueStoreMaterializerTest method shouldCreateBuilderThatBuildsMeteredStoreWithCachingAndLoggingEnabled.
@Test
public void shouldCreateBuilderThatBuildsMeteredStoreWithCachingAndLoggingEnabled() {
final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<String, String, KeyValueStore<Bytes, byte[]>>as("store"), nameProvider, storePrefix);
final KeyValueStoreMaterializer<String, String> materializer = new KeyValueStoreMaterializer<>(materialized);
final StoreBuilder<KeyValueStore<String, String>> builder = materializer.materialize();
final KeyValueStore<String, String> store = builder.build();
final WrappedStateStore caching = (WrappedStateStore) ((WrappedStateStore) store).wrappedStore();
final StateStore logging = caching.wrappedStore();
assertThat(store, instanceOf(MeteredKeyValueBytesStore.class));
assertThat(caching, instanceOf(CachedStateStore.class));
assertThat(logging, instanceOf(ChangeLoggingKeyValueBytesStore.class));
}
Aggregations