Search in sources :

Example 1 with WindowBytesStoreSupplier

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

the class KStreamKStreamJoinTest method shouldThrowExceptionOtherStoreSupplierWindowSizeDoesNotMatchJoinWindowsWindowSize.

@Test
public void shouldThrowExceptionOtherStoreSupplierWindowSizeDoesNotMatchJoinWindowsWindowSize() {
    // Case where window size of otherJoinStore doesn't match JoinWindows
    final WindowBytesStoreSupplier thisStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store", 150L, 100L, true);
    final WindowBytesStoreSupplier otherStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store-other", 150L, 150L, true);
    buildStreamsJoinThatShouldThrow(streamJoined.withThisStoreSupplier(thisStoreSupplier).withOtherStoreSupplier(otherStoreSupplier), joinWindows, errorMessagePrefix);
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) Test(org.junit.Test)

Example 2 with WindowBytesStoreSupplier

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

the class KStreamKStreamJoinTest method shouldExceptionWhenJoinStoresDoNotHaveUniqueNames.

@Test
public void shouldExceptionWhenJoinStoresDoNotHaveUniqueNames() {
    final JoinWindows joinWindows = JoinWindows.ofTimeDifferenceAndGrace(ofMillis(100L), Duration.ofMillis(50L));
    final StreamJoined<String, Integer, Integer> streamJoined = StreamJoined.with(Serdes.String(), Serdes.Integer(), Serdes.Integer());
    final WindowBytesStoreSupplier thisStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store", 150L, 100L, true);
    final WindowBytesStoreSupplier otherStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store", 150L, 100L, true);
    buildStreamsJoinThatShouldThrow(streamJoined.withThisStoreSupplier(thisStoreSupplier).withOtherStoreSupplier(otherStoreSupplier), joinWindows, "Both StoreSuppliers have the same name.  StoreSuppliers must provide unique names");
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) JoinWindows(org.apache.kafka.streams.kstream.JoinWindows) Test(org.junit.Test)

Example 3 with WindowBytesStoreSupplier

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

the class KStreamKStreamJoinTest method shouldThrowExceptionThisStoreSupplierRetentionDoNotMatchWindowsSizeAndGrace.

@Test
public void shouldThrowExceptionThisStoreSupplierRetentionDoNotMatchWindowsSizeAndGrace() {
    // Case where retention of thisJoinStore doesn't match JoinWindows
    final WindowBytesStoreSupplier thisStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store", 500L, 100L, true);
    final WindowBytesStoreSupplier otherStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store-other", 150L, 100L, true);
    buildStreamsJoinThatShouldThrow(streamJoined.withThisStoreSupplier(thisStoreSupplier).withOtherStoreSupplier(otherStoreSupplier), joinWindows, errorMessagePrefix);
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) Test(org.junit.Test)

Example 4 with WindowBytesStoreSupplier

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

the class KStreamKStreamJoinTest method shouldThrowExceptionWhenThisJoinStoreSetsRetainDuplicatesFalse.

@Test
public void shouldThrowExceptionWhenThisJoinStoreSetsRetainDuplicatesFalse() {
    // Case where thisJoinStore retain duplicates false
    final WindowBytesStoreSupplier thisStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store", 150L, 100L, false);
    final WindowBytesStoreSupplier otherStoreSupplier = buildWindowBytesStoreSupplier("in-memory-join-store-other", 150L, 100L, true);
    buildStreamsJoinThatShouldThrow(streamJoined.withThisStoreSupplier(thisStoreSupplier).withOtherStoreSupplier(otherStoreSupplier), joinWindows, "The StoreSupplier must set retainDuplicates=true, found retainDuplicates=false");
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) Test(org.junit.Test)

Example 5 with WindowBytesStoreSupplier

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

the class KStreamKStreamLeftJoinTest method testLeftJoinWithInMemoryCustomSuppliers.

@Test
public void testLeftJoinWithInMemoryCustomSuppliers() {
    final JoinWindows joinWindows = JoinWindows.ofTimeDifferenceAndGrace(ofMillis(100L), ofMillis(0L));
    final WindowBytesStoreSupplier thisStoreSupplier = Stores.inMemoryWindowStore("in-memory-join-store", Duration.ofMillis(joinWindows.size() + joinWindows.gracePeriodMs()), Duration.ofMillis(joinWindows.size()), true);
    final WindowBytesStoreSupplier otherStoreSupplier = Stores.inMemoryWindowStore("in-memory-join-store-other", Duration.ofMillis(joinWindows.size() + joinWindows.gracePeriodMs()), Duration.ofMillis(joinWindows.size()), true);
    final StreamJoined<Integer, String, String> streamJoined = StreamJoined.with(Serdes.Integer(), Serdes.String(), Serdes.String());
    runLeftJoin(streamJoined.withThisStoreSupplier(thisStoreSupplier).withOtherStoreSupplier(otherStoreSupplier), joinWindows);
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) JoinWindows(org.apache.kafka.streams.kstream.JoinWindows) Test(org.junit.Test)

Aggregations

WindowBytesStoreSupplier (org.apache.kafka.streams.state.WindowBytesStoreSupplier)31 Test (org.junit.Test)21 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)9 StringSerializer (org.apache.kafka.common.serialization.StringSerializer)8 TopologyTestDriver (org.apache.kafka.streams.TopologyTestDriver)8 Windowed (org.apache.kafka.streams.kstream.Windowed)8 JoinWindows (org.apache.kafka.streams.kstream.JoinWindows)7 InMemoryWindowBytesStoreSupplier (org.apache.kafka.streams.state.internals.InMemoryWindowBytesStoreSupplier)7 MockApiProcessorSupplier (org.apache.kafka.test.MockApiProcessorSupplier)6 TimestampedWindowStore (org.apache.kafka.streams.state.TimestampedWindowStore)4 ValueAndTimestamp (org.apache.kafka.streams.state.ValueAndTimestamp)4 WindowStore (org.apache.kafka.streams.state.WindowStore)4 HashMap (java.util.HashMap)3 KeyValueBytesStoreSupplier (org.apache.kafka.streams.state.KeyValueBytesStoreSupplier)3 SessionBytesStoreSupplier (org.apache.kafka.streams.state.SessionBytesStoreSupplier)3 KeyValueTimestamp (org.apache.kafka.streams.KeyValueTimestamp)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Properties (java.util.Properties)1