use of org.apache.kafka.streams.state.KeyValueBytesStoreSupplier in project kafka by apache.
the class RangeQueryIntegrationTest method getStoreConfig.
private Materialized<String, String, KeyValueStore<Bytes, byte[]>> getStoreConfig(final StoreType type, final boolean cachingEnabled, final boolean loggingEnabled) {
final Supplier<KeyValueBytesStoreSupplier> createStore = () -> {
if (type == StoreType.InMemory) {
return Stores.inMemoryKeyValueStore(TABLE_NAME);
} else if (type == StoreType.RocksDB) {
return Stores.persistentKeyValueStore(TABLE_NAME);
} else if (type == StoreType.Timed) {
return Stores.persistentTimestampedKeyValueStore(TABLE_NAME);
} else {
return Stores.inMemoryKeyValueStore(TABLE_NAME);
}
};
final KeyValueBytesStoreSupplier stateStoreSupplier = createStore.get();
final Materialized<String, String, KeyValueStore<Bytes, byte[]>> stateStoreConfig = Materialized.<String, String>as(stateStoreSupplier).withKeySerde(Serdes.String()).withValueSerde(Serdes.String());
if (cachingEnabled) {
stateStoreConfig.withCachingEnabled();
} else {
stateStoreConfig.withCachingDisabled();
}
if (loggingEnabled) {
stateStoreConfig.withLoggingEnabled(new HashMap<>());
} else {
stateStoreConfig.withLoggingDisabled();
}
return stateStoreConfig;
}
use of org.apache.kafka.streams.state.KeyValueBytesStoreSupplier in project kafka by apache.
the class PositionRestartIntegrationTest method beforeTest.
public void beforeTest(final boolean cleanup) {
final StoreSupplier<?> supplier = storeToTest.supplier();
final StreamsBuilder builder = new StreamsBuilder();
if (Objects.equals(kind, "DSL") && supplier instanceof KeyValueBytesStoreSupplier) {
setUpKeyValueDSLTopology((KeyValueBytesStoreSupplier) supplier, builder);
} else if (Objects.equals(kind, "PAPI") && supplier instanceof KeyValueBytesStoreSupplier) {
setUpKeyValuePAPITopology((KeyValueBytesStoreSupplier) supplier, builder);
} else if (Objects.equals(kind, "DSL") && supplier instanceof WindowBytesStoreSupplier) {
setUpWindowDSLTopology((WindowBytesStoreSupplier) supplier, builder);
} else if (Objects.equals(kind, "PAPI") && supplier instanceof WindowBytesStoreSupplier) {
setUpWindowPAPITopology((WindowBytesStoreSupplier) supplier, builder);
} else if (Objects.equals(kind, "DSL") && supplier instanceof SessionBytesStoreSupplier) {
setUpSessionDSLTopology((SessionBytesStoreSupplier) supplier, builder);
} else if (Objects.equals(kind, "PAPI") && supplier instanceof SessionBytesStoreSupplier) {
setUpSessionPAPITopology((SessionBytesStoreSupplier) supplier, builder);
} else {
throw new AssertionError("Store supplier is an unrecognized type.");
}
kafkaStreams = IntegrationTestUtils.getStartedStreams(streamsConfig, builder, cleanup);
}
use of org.apache.kafka.streams.state.KeyValueBytesStoreSupplier in project kafkastreams-cep by fhussonnois.
the class QueryStoreBuilders method getAggregateStateStore.
/**
* Build all {@link StoreBuilder} used to store aggregate states for stages.
*
* @return a new collection of {@link StoreBuilder}.
*/
public StoreBuilder<AggregatesStateStore<K>> getAggregateStateStore(final Queried<K, V> queried) {
final String storeName = QueryStores.getQueryAggregateStatesStoreName(queryName);
final QueriedInternal<K, V> internal = new QueriedInternal<>(queried);
KeyValueBytesStoreSupplier supplier = (KeyValueBytesStoreSupplier) internal.storeSupplier();
if (supplier == null) {
supplier = Stores.persistentKeyValueStore(storeName);
}
final StoreBuilder<AggregatesStateStore<K>> builder = QueryStores.aggregatesStoreBuilder(supplier);
return mayEnableCaching(internal, mayEnableLogging(internal, builder));
}
use of org.apache.kafka.streams.state.KeyValueBytesStoreSupplier in project kafkastreams-cep by fhussonnois.
the class QueryStoreBuilders method getEventBufferStore.
/**
* Build a new {@link StoreBuilder} used to store match sequences.
*
* @param queried the {@link Queried} instance.
*
* @return a new {@link StoreBuilder} instance.
*/
public StoreBuilder<SharedVersionedBufferStateStore<K, V>> getEventBufferStore(final Queried<K, V> queried) {
final String storeName = QueryStores.getQueryEventBufferStoreName(queryName);
final QueriedInternal<K, V> internal = new QueriedInternal<>(queried);
KeyValueBytesStoreSupplier supplier = (KeyValueBytesStoreSupplier) internal.storeSupplier();
if (supplier == null) {
supplier = Stores.persistentKeyValueStore(storeName);
}
StoreBuilder<SharedVersionedBufferStateStore<K, V>> builder = QueryStores.bufferStoreBuilder(supplier, internal.keySerde(), internal.valueSerde());
return mayEnableCaching(internal, mayEnableLogging(internal, builder));
}
use of org.apache.kafka.streams.state.KeyValueBytesStoreSupplier in project kafkastreams-cep by fhussonnois.
the class QueryStoreBuilders method getNFAStateStore.
/**
* Build a persistent {@link StoreBuilder}.
*
* @param queried the {@link Queried} instance.
*
* @return a new {@link StoreBuilder} instance.
*/
public StoreBuilder<NFAStateStore<K, V>> getNFAStateStore(final Queried<K, V> queried) {
final String storeName = QueryStores.getQueryNFAStoreName(queryName);
final QueriedInternal<K, V> internal = new QueriedInternal<>(queried);
KeyValueBytesStoreSupplier supplier = (KeyValueBytesStoreSupplier) internal.storeSupplier();
if (supplier == null) {
supplier = Stores.persistentKeyValueStore(storeName);
}
final NFAStoreBuilder<K, V> builder = QueryStores.nfaStoreBuilder(supplier, stages.getAllStages(), internal.keySerde(), internal.valueSerde());
return mayEnableCaching(internal, mayEnableLogging(internal, builder));
}
Aggregations