Search in sources :

Example 1 with TimestampedKeyValueStore

use of org.apache.kafka.streams.state.TimestampedKeyValueStore 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 2 with TimestampedKeyValueStore

use of org.apache.kafka.streams.state.TimestampedKeyValueStore 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 3 with TimestampedKeyValueStore

use of org.apache.kafka.streams.state.TimestampedKeyValueStore 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)

Example 4 with TimestampedKeyValueStore

use of org.apache.kafka.streams.state.TimestampedKeyValueStore in project kafka by apache.

the class TimestampedKeyValueStoreMaterializerTest method shouldCreateKeyValueStoreWithTheProvidedInnerStore.

@Test
public void shouldCreateKeyValueStoreWithTheProvidedInnerStore() {
    final KeyValueBytesStoreSupplier supplier = EasyMock.createNiceMock(KeyValueBytesStoreSupplier.class);
    final InMemoryKeyValueStore store = new InMemoryKeyValueStore("name");
    EasyMock.expect(supplier.name()).andReturn("name").anyTimes();
    EasyMock.expect(supplier.get()).andReturn(store);
    EasyMock.expect(supplier.metricsScope()).andReturn("metricScope");
    EasyMock.replay(supplier);
    final MaterializedInternal<String, Integer, KeyValueStore<Bytes, byte[]>> materialized = new MaterializedInternal<>(Materialized.as(supplier), nameProvider, storePrefix);
    final TimestampedKeyValueStoreMaterializer<String, Integer> materializer = new TimestampedKeyValueStoreMaterializer<>(materialized);
    final StoreBuilder<TimestampedKeyValueStore<String, Integer>> builder = materializer.materialize();
    final TimestampedKeyValueStore<String, Integer> built = builder.build();
    assertThat(store.name(), CoreMatchers.equalTo(built.name()));
}
Also used : TimestampedKeyValueStoreMaterializer(org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer) KeyValueBytesStoreSupplier(org.apache.kafka.streams.state.KeyValueBytesStoreSupplier) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) 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) InMemoryKeyValueStore(org.apache.kafka.streams.state.internals.InMemoryKeyValueStore) Test(org.junit.Test)

Example 5 with TimestampedKeyValueStore

use of org.apache.kafka.streams.state.TimestampedKeyValueStore in project kafka by apache.

the class TimestampedKeyValueStoreMaterializerTest 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 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();
    assertThat(caching, instanceOf(CachingKeyValueStore.class));
    assertThat(caching.wrapped(), not(instanceOf(ChangeLoggingKeyValueBytesStore.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) TimestampedKeyValueStore(org.apache.kafka.streams.state.TimestampedKeyValueStore) MeteredTimestampedKeyValueStore(org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore) 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

TimestampedKeyValueStore (org.apache.kafka.streams.state.TimestampedKeyValueStore)10 MaterializedInternal (org.apache.kafka.streams.kstream.internals.MaterializedInternal)5 TimestampedKeyValueStoreMaterializer (org.apache.kafka.streams.kstream.internals.TimestampedKeyValueStoreMaterializer)5 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)5 CachingKeyValueStore (org.apache.kafka.streams.state.internals.CachingKeyValueStore)5 InMemoryKeyValueStore (org.apache.kafka.streams.state.internals.InMemoryKeyValueStore)5 MeteredTimestampedKeyValueStore (org.apache.kafka.streams.state.internals.MeteredTimestampedKeyValueStore)5 Test (org.junit.Test)5 WrappedStateStore (org.apache.kafka.streams.state.internals.WrappedStateStore)4 GraphNode (org.apache.kafka.streams.kstream.internals.graph.GraphNode)3 ProcessorGraphNode (org.apache.kafka.streams.kstream.internals.graph.ProcessorGraphNode)3 TableProcessorNode (org.apache.kafka.streams.kstream.internals.graph.TableProcessorNode)3 Bytes (org.apache.kafka.common.utils.Bytes)2 StateStore (org.apache.kafka.streams.processor.StateStore)2 KeyValueBytesStoreSupplier (org.apache.kafka.streams.state.KeyValueBytesStoreSupplier)2 UnsupportedVersionException (org.apache.kafka.common.errors.UnsupportedVersionException)1 Sensor (org.apache.kafka.common.metrics.Sensor)1 Change (org.apache.kafka.streams.kstream.internals.Change)1 ContextualProcessor (org.apache.kafka.streams.processor.api.ContextualProcessor)1 ProcessorContext (org.apache.kafka.streams.processor.api.ProcessorContext)1