Search in sources :

Example 1 with WrappedStateStore

use of org.apache.kafka.streams.state.internals.WrappedStateStore 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)));
}
Also used : WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) CachedStateStore(org.apache.kafka.streams.state.internals.CachedStateStore) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) MaterializedInternal(org.apache.kafka.streams.kstream.internals.MaterializedInternal) KeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer) Test(org.junit.Test)

Example 2 with WrappedStateStore

use of org.apache.kafka.streams.state.internals.WrappedStateStore 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));
}
Also used : WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) CachedStateStore(org.apache.kafka.streams.state.internals.CachedStateStore) StateStore(org.apache.kafka.streams.processor.StateStore) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) Bytes(org.apache.kafka.common.utils.Bytes) KeyValueBytesStoreSupplier(org.apache.kafka.streams.state.KeyValueBytesStoreSupplier) MaterializedInternal(org.apache.kafka.streams.kstream.internals.MaterializedInternal) KeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) Test(org.junit.Test)

Example 3 with WrappedStateStore

use of org.apache.kafka.streams.state.internals.WrappedStateStore in project kafka by apache.

the class TimestampedKeyValueStoreMaterializerTest method shouldCreateBuilderThatBuildsStoreWithCachingAndLoggingDisabled.

@Test
public void shouldCreateBuilderThatBuildsStoreWithCachingAndLoggingDisabled() {
    final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.<String, String, KeyValueStore<Bytes, byte[]>>as("store").withCachingDisabled().withLoggingDisabled(), nameProvider, storePrefix);
    final TimestampedKeyValueStoreMaterializer<String, String> materializer = new TimestampedKeyValueStoreMaterializer<>(materialized);
    final StoreBuilder<TimestampedKeyValueStore<String, String>> builder = materializer.materialize();
    final TimestampedKeyValueStore<String, String> store = builder.build();
    final StateStore wrapped = ((WrappedStateStore) store).wrapped();
    assertThat(wrapped, not(instanceOf(CachingKeyValueStore.class)));
    assertThat(wrapped, not(instanceOf(ChangeLoggingKeyValueBytesStore.class)));
}
Also used : Bytes(org.apache.kafka.common.utils.Bytes) TimestampedKeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) StateStore(org.apache.kafka.streams.processor.StateStore) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) CachingKeyValueStore(org.apache.kafka.streams.state.internals.CachingKeyValueStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) MaterializedInternal(org.apache.kafka.streams.kstream.internals.MaterializedInternal) Test(org.junit.Test)

Example 4 with WrappedStateStore

use of org.apache.kafka.streams.state.internals.WrappedStateStore in project kafka by apache.

the class TimestampedKeyValueStoreMaterializerTest method shouldCreateBuilderThatBuildsMeteredStoreWithCachingAndLoggingEnabled.

@Test
public void shouldCreateBuilderThatBuildsMeteredStoreWithCachingAndLoggingEnabled() {
    final MaterializedInternal<String, String, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.as("store"), nameProvider, storePrefix);
    final TimestampedKeyValueStoreMaterializer<String, String> materializer = new TimestampedKeyValueStoreMaterializer<>(materialized);
    final StoreBuilder<TimestampedKeyValueStore<String, String>> builder = materializer.materialize();
    final TimestampedKeyValueStore<String, String> store = builder.build();
    final WrappedStateStore caching = (WrappedStateStore) ((WrappedStateStore) store).wrapped();
    final StateStore logging = caching.wrapped();
    assertThat(store, instanceOf(MeteredTimestampedKeyValueStore.class));
    assertThat(caching, instanceOf(CachingKeyValueStore.class));
    assertThat(logging, instanceOf(ChangeLoggingTimestampedKeyValueBytesStore.class));
}
Also used : TimestampedKeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer) CachingKeyValueStore(org.apache.kafka.streams.state.internals.CachingKeyValueStore) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) StateStore(org.apache.kafka.streams.processor.StateStore) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) CachingKeyValueStore(org.apache.kafka.streams.state.internals.CachingKeyValueStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) ChangeLoggingTimestampedKeyValueBytesStore(org.apache.kafka.streams.state.internals.ChangeLoggingTimestampedKeyValueBytesStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) MaterializedInternal(org.apache.kafka.streams.kstream.internals.MaterializedInternal) Test(org.junit.Test)

Example 5 with WrappedStateStore

use of org.apache.kafka.streams.state.internals.WrappedStateStore in project kafka by apache.

the class TimestampedKeyValueStoreMaterializerTest 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 TimestampedKeyValueStoreMaterializer<String, String> materializer = new TimestampedKeyValueStoreMaterializer<>(materialized);
    final StoreBuilder<TimestampedKeyValueStore<String, String>> builder = materializer.materialize();
    final TimestampedKeyValueStore<String, String> store = builder.build();
    final WrappedStateStore logging = (WrappedStateStore) ((WrappedStateStore) store).wrapped();
    assertThat(logging, instanceOf(ChangeLoggingKeyValueBytesStore.class));
}
Also used : TimestampedKeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer) WrappedStateStore(org.apache.kafka.streams.state.internals.WrappedStateStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) ChangeLoggingKeyValueBytesStore(org.apache.kafka.streams.state.internals.ChangeLoggingKeyValueBytesStore) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) CachingKeyValueStore(org.apache.kafka.streams.state.internals.CachingKeyValueStore) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) MaterializedInternal(org.apache.kafka.streams.kstream.internals.MaterializedInternal) Test(org.junit.Test)

Aggregations

WrappedStateStore (org.apache.kafka.streams.state.internals.WrappedStateStore)11 Test (org.junit.Test)11 MaterializedInternal (org.apache.kafka.streams.kstream.internals.MaterializedInternal)9 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)9 InMemoryKeyValueStore (org.apache.kafka.streams.state.internals.InMemoryKeyValueStore)9 StateStore (org.apache.kafka.streams.processor.StateStore)7 KeyValueStoreMaterializer (org.apache.kafka.streams.kstream.internals.KeyValueStoreMaterializer)5 Bytes (org.apache.kafka.common.utils.Bytes)4 TimestampedKeyValueStoreMaterializer (org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer)4 TimestampedKeyValueStore (org.apache.kafka.streams.state.TimestampedKeyValueStore)4 CachedStateStore (org.apache.kafka.streams.state.internals.CachedStateStore)4 CachingKeyValueStore (org.apache.kafka.streams.state.internals.CachingKeyValueStore)4 MeteredTimestampedKeyValueStore (org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore)4 ChangeLoggingKeyValueBytesStore (org.apache.kafka.streams.state.internals.ChangeLoggingKeyValueBytesStore)3 RocksDBTimestampedSegmentedBytesStore (org.apache.kafka.streams.state.internals.RocksDBTimestampedSegmentedBytesStore)2 RocksDBWindowStore (org.apache.kafka.streams.state.internals.RocksDBWindowStore)2 KeyValueBytesStoreSupplier (org.apache.kafka.streams.state.KeyValueBytesStoreSupplier)1 ChangeLoggingTimestampedKeyValueBytesStore (org.apache.kafka.streams.state.internals.ChangeLoggingTimestampedKeyValueBytesStore)1 MeteredKeyValueBytesStore (org.apache.kafka.streams.state.internals.MeteredKeyValueBytesStore)1