Search in sources :

Example 1 with NotRunningException

use of io.confluent.ksql.execution.streams.materialization.NotRunningException in project ksql by confluentinc.

the class KsStateStore method store.

<T> T store(final QueryableStoreType<T> queryableStoreType, final int partition) {
    try {
        final boolean enableStaleStores = ksqlConfig.getBoolean(KsqlConfig.KSQL_QUERY_PULL_ENABLE_STANDBY_READS);
        final boolean sharedRuntime = kafkaStreams instanceof KafkaStreamsNamedTopologyWrapper;
        final StoreQueryParameters<T> parameters = sharedRuntime ? NamedTopologyStoreQueryParameters.fromNamedTopologyAndStoreNameAndType(queryId, stateStoreName, queryableStoreType).withPartition(partition) : StoreQueryParameters.fromNameAndType(stateStoreName, queryableStoreType).withPartition(partition);
        return enableStaleStores ? kafkaStreams.store(parameters.enableStaleStores()) : kafkaStreams.store(parameters);
    } catch (final Exception e) {
        final State state = kafkaStreams.state();
        if (state != State.RUNNING) {
            throw new NotRunningException("The query was not in a running state. state: " + state);
        }
        throw new MaterializationException("State store currently unavailable: " + stateStoreName, e);
    }
}
Also used : KafkaStreamsNamedTopologyWrapper(org.apache.kafka.streams.processor.internals.namedtopology.KafkaStreamsNamedTopologyWrapper) State(org.apache.kafka.streams.KafkaStreams.State) NotRunningException(io.confluent.ksql.execution.streams.materialization.NotRunningException) MaterializationException(io.confluent.ksql.execution.streams.materialization.MaterializationException) NotRunningException(io.confluent.ksql.execution.streams.materialization.NotRunningException) MaterializationException(io.confluent.ksql.execution.streams.materialization.MaterializationException)

Aggregations

MaterializationException (io.confluent.ksql.execution.streams.materialization.MaterializationException)1 NotRunningException (io.confluent.ksql.execution.streams.materialization.NotRunningException)1 State (org.apache.kafka.streams.KafkaStreams.State)1 KafkaStreamsNamedTopologyWrapper (org.apache.kafka.streams.processor.internals.namedtopology.KafkaStreamsNamedTopologyWrapper)1