use of org.apache.kafka.streams.kstream.internals.SessionWindow in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method testUpperBoundWithZeroTimestamp.
@Test
public void testUpperBoundWithZeroTimestamp() {
Bytes upper = sessionKeySchema.upperRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), 0);
assertThat(upper, equalTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), new SessionWindow(0, 0))))));
}
use of org.apache.kafka.streams.kstream.internals.SessionWindow in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method shouldWriteBytesToInnerStoreAndRecordPutMetric.
@Test
public void shouldWriteBytesToInnerStoreAndRecordPutMetric() {
inner.put(EasyMock.eq(windowedKeyBytes), EasyMock.aryEq(keyBytes));
EasyMock.expectLastCall();
init();
metered.put(new Windowed<>(key, new SessionWindow(0, 0)), key);
final KafkaMetric metric = metric("put-rate");
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
use of org.apache.kafka.streams.kstream.internals.SessionWindow in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method shouldRemoveFromStoreAndRecordRemoveMetric.
@Test
public void shouldRemoveFromStoreAndRecordRemoveMetric() {
inner.remove(windowedKeyBytes);
EasyMock.expectLastCall();
init();
metered.remove(new Windowed<>(key, new SessionWindow(0, 0)));
final KafkaMetric metric = metric("remove-rate");
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
use of org.apache.kafka.streams.kstream.internals.SessionWindow in project apache-kafka-on-k8s by banzaicloud.
the class RocksDBSegmentedBytesStoreTest method shouldGetAllSegments.
@Test
public void shouldGetAllSegments() {
// just to validate directories
final Segments segments = new Segments(storeName, retention, numSegments);
final String key = "a";
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(0L, 0L))), serializeValue(50L));
assertEquals(Collections.singleton(segments.segmentName(0)), segmentDirs());
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(30000L, 60000L))), serializeValue(100L));
assertEquals(Utils.mkSet(segments.segmentName(0), segments.segmentName(1)), segmentDirs());
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(61000L, 120000L))), serializeValue(200L));
assertEquals(Utils.mkSet(segments.segmentName(0), segments.segmentName(1), segments.segmentName(2)), segmentDirs());
final List<KeyValue<Windowed<String>, Long>> results = toList(bytesStore.all());
assertEquals(Arrays.asList(KeyValue.pair(new Windowed<>(key, new SessionWindow(0L, 0L)), 50L), KeyValue.pair(new Windowed<>(key, new SessionWindow(30000L, 60000L)), 100L), KeyValue.pair(new Windowed<>(key, new SessionWindow(61000L, 120000L)), 200L)), results);
}
use of org.apache.kafka.streams.kstream.internals.SessionWindow in project apache-kafka-on-k8s by banzaicloud.
the class RocksDBSegmentedBytesStoreTest method shouldFetchAllSegments.
@Test
public void shouldFetchAllSegments() {
// just to validate directories
final Segments segments = new Segments(storeName, retention, numSegments);
final String key = "a";
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(0L, 0L))), serializeValue(50L));
assertEquals(Collections.singleton(segments.segmentName(0)), segmentDirs());
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(30000L, 60000L))), serializeValue(100L));
assertEquals(Utils.mkSet(segments.segmentName(0), segments.segmentName(1)), segmentDirs());
bytesStore.put(serializeKey(new Windowed<>(key, new SessionWindow(61000L, 120000L))), serializeValue(200L));
assertEquals(Utils.mkSet(segments.segmentName(0), segments.segmentName(1), segments.segmentName(2)), segmentDirs());
final List<KeyValue<Windowed<String>, Long>> results = toList(bytesStore.fetchAll(0L, 60000L));
assertEquals(Arrays.asList(KeyValue.pair(new Windowed<>(key, new SessionWindow(0L, 0L)), 50L), KeyValue.pair(new Windowed<>(key, new SessionWindow(30000L, 60000L)), 100L)), results);
}
Aggregations