Search in sources :

Example 6 with ReadOnlySessionStore

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

the class CompositeReadOnlySessionStore method fetchSession.

@Override
public V fetchSession(final K key, final long earliestSessionEndTime, final long latestSessionStartTime) {
    Objects.requireNonNull(key, "key can't be null");
    final List<ReadOnlySessionStore<K, V>> stores = storeProvider.stores(storeName, queryableStoreType);
    for (final ReadOnlySessionStore<K, V> store : stores) {
        try {
            return store.fetchSession(key, earliestSessionEndTime, latestSessionStartTime);
        } catch (final InvalidStateStoreException ise) {
            throw new InvalidStateStoreException("State store  [" + storeName + "] is not available anymore" + " and may have been migrated to another instance; " + "please re-discover its location from the state metadata.", ise);
        }
    }
    return null;
}
Also used : InvalidStateStoreException(org.apache.kafka.streams.errors.InvalidStateStoreException) ReadOnlySessionStore(org.apache.kafka.streams.state.ReadOnlySessionStore)

Example 7 with ReadOnlySessionStore

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

the class CompositeReadOnlySessionStoreTest method shouldThrowInvalidStateStoreExceptionOnRebalance.

@Test
public void shouldThrowInvalidStateStoreExceptionOnRebalance() {
    final QueryableStoreType<ReadOnlySessionStore<Object, Object>> queryableStoreType = QueryableStoreTypes.sessionStore();
    final CompositeReadOnlySessionStore<String, String> store = new CompositeReadOnlySessionStore<>(new WrappingStoreProvider(singletonList(new StateStoreProviderStub(true)), StoreQueryParameters.fromNameAndType("whateva", queryableStoreType)), QueryableStoreTypes.sessionStore(), "whateva");
    assertThrows(InvalidStateStoreException.class, () -> store.fetch("a"));
}
Also used : ReadOnlySessionStore(org.apache.kafka.streams.state.ReadOnlySessionStore) StateStoreProviderStub(org.apache.kafka.test.StateStoreProviderStub) Test(org.junit.Test)

Aggregations

ReadOnlySessionStore (org.apache.kafka.streams.state.ReadOnlySessionStore)7 InvalidStateStoreException (org.apache.kafka.streams.errors.InvalidStateStoreException)6 Windowed (org.apache.kafka.streams.kstream.Windowed)5 StateStoreProviderStub (org.apache.kafka.test.StateStoreProviderStub)1 Test (org.junit.Test)1