Search in sources :

Example 1 with CEPProcessor

use of com.github.fhuss.kafka.streams.cep.processor.CEPProcessor in project kafkastreams-cep by fhussonnois.

the class CEPStreamImpl method query.

/**
 * {@inheritDoc}
 */
@Override
public KStream<K, Sequence<K, V>> query(String queryName, Pattern<K, V> pattern, Queried<K, V> queried) {
    Objects.requireNonNull(queryName, "queryName can't be null");
    Objects.requireNonNull(pattern, "pattern can't be null");
    final String name = builder.newProcessorName("CEPSTREAM-QUERY-" + queryName.toUpperCase() + "-");
    final ProcessorSupplier processor = () -> new CEPProcessor<>(queryName, pattern);
    builder.internalTopologyBuilder.addProcessor(name, processor, this.name);
    QueryStoreBuilders<K, V> storeBuilders = new QueryStoreBuilders<>(queryName, pattern);
    final Serde<K> keySerde = (queried == null) ? null : queried.keySerde();
    final Serde<V> valSerde = (queried == null) ? null : queried.valueSerde();
    addStateStore(storeBuilders.getNFAStateStoreBuilder(keySerde, valSerde), name);
    addStateStore(storeBuilders.getEventBufferStoreBuilder(keySerde, valSerde), name);
    addStateStore(storeBuilders.getAggregateStateStores(), name);
    return new KStreamImpl<>(builder, name, sourceNodes, false);
}
Also used : CEPProcessor(com.github.fhuss.kafka.streams.cep.processor.CEPProcessor) ProcessorSupplier(org.apache.kafka.streams.processor.ProcessorSupplier) QueryStoreBuilders(com.github.fhuss.kafka.streams.cep.state.QueryStoreBuilders)

Aggregations

CEPProcessor (com.github.fhuss.kafka.streams.cep.processor.CEPProcessor)1 QueryStoreBuilders (com.github.fhuss.kafka.streams.cep.state.QueryStoreBuilders)1 ProcessorSupplier (org.apache.kafka.streams.processor.ProcessorSupplier)1