use of org.apache.kafka.streams.state.WindowStoreIterator in project kafka by apache.
the class RocksDBWindowStoreTest method testInitialLoading.
@SuppressWarnings("unchecked")
@Test
public void testInitialLoading() throws IOException {
File storeDir = new File(baseDir, windowName);
windowStore = createWindowStore(context, false, true);
new File(storeDir, segments.segmentName(0L)).mkdir();
new File(storeDir, segments.segmentName(1L)).mkdir();
new File(storeDir, segments.segmentName(2L)).mkdir();
new File(storeDir, segments.segmentName(3L)).mkdir();
new File(storeDir, segments.segmentName(4L)).mkdir();
new File(storeDir, segments.segmentName(5L)).mkdir();
new File(storeDir, segments.segmentName(6L)).mkdir();
windowStore.close();
windowStore = createWindowStore(context, false, true);
assertEquals(Utils.mkSet(segments.segmentName(4L), segments.segmentName(5L), segments.segmentName(6L)), segmentDirs(baseDir));
try (WindowStoreIterator iter = windowStore.fetch(0, 0L, 1000000L)) {
while (iter.hasNext()) {
iter.next();
}
}
assertEquals(Utils.mkSet(segments.segmentName(4L), segments.segmentName(5L), segments.segmentName(6L)), segmentDirs(baseDir));
}
use of org.apache.kafka.streams.state.WindowStoreIterator in project kafka by apache.
the class RocksDBWindowStoreTest method testSegmentMaintenance.
@SuppressWarnings("unchecked")
@Test
public void testSegmentMaintenance() throws IOException {
windowStore = createWindowStore(context, false, true);
context.setTime(0L);
context.setRecordContext(createRecordContext(0));
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(59999));
windowStore.put(0, "v");
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(60000));
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L), segments.segmentName(1L)), segmentDirs(baseDir));
WindowStoreIterator iter;
int fetchedCount;
iter = windowStore.fetch(0, 0L, 240000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(4, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(0L), segments.segmentName(1L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(180000));
windowStore.put(0, "v");
iter = windowStore.fetch(0, 0L, 240000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(2, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(1L), segments.segmentName(3L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(300000));
windowStore.put(0, "v");
iter = windowStore.fetch(0, 240000L, 1000000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(1, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(3L), segments.segmentName(5L)), segmentDirs(baseDir));
}
use of org.apache.kafka.streams.state.WindowStoreIterator in project apache-kafka-on-k8s by banzaicloud.
the class RocksDBWindowStoreTest method testSegmentMaintenance.
@Test
public void testSegmentMaintenance() {
windowStore = createWindowStore(context, true);
context.setTime(0L);
context.setRecordContext(createRecordContext(0));
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(59999));
windowStore.put(0, "v");
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(60000));
windowStore.put(0, "v");
assertEquals(Utils.mkSet(segments.segmentName(0L), segments.segmentName(1L)), segmentDirs(baseDir));
WindowStoreIterator iter;
int fetchedCount;
iter = windowStore.fetch(0, 0L, 240000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(4, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(0L), segments.segmentName(1L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(180000));
windowStore.put(0, "v");
iter = windowStore.fetch(0, 0L, 240000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(2, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(1L), segments.segmentName(3L)), segmentDirs(baseDir));
context.setRecordContext(createRecordContext(300000));
windowStore.put(0, "v");
iter = windowStore.fetch(0, 240000L, 1000000L);
fetchedCount = 0;
while (iter.hasNext()) {
iter.next();
fetchedCount++;
}
assertEquals(1, fetchedCount);
assertEquals(Utils.mkSet(segments.segmentName(3L), segments.segmentName(5L)), segmentDirs(baseDir));
}
use of org.apache.kafka.streams.state.WindowStoreIterator in project apache-kafka-on-k8s by banzaicloud.
the class RocksDBWindowStoreTest method testInitialLoading.
@Test
public void testInitialLoading() {
File storeDir = new File(baseDir, windowName);
windowStore = createWindowStore(context);
new File(storeDir, segments.segmentName(0L)).mkdir();
new File(storeDir, segments.segmentName(1L)).mkdir();
new File(storeDir, segments.segmentName(2L)).mkdir();
new File(storeDir, segments.segmentName(3L)).mkdir();
new File(storeDir, segments.segmentName(4L)).mkdir();
new File(storeDir, segments.segmentName(5L)).mkdir();
new File(storeDir, segments.segmentName(6L)).mkdir();
windowStore.close();
windowStore = createWindowStore(context);
assertEquals(Utils.mkSet(segments.segmentName(4L), segments.segmentName(5L), segments.segmentName(6L)), segmentDirs(baseDir));
try (WindowStoreIterator iter = windowStore.fetch(0, 0L, 1000000L)) {
while (iter.hasNext()) {
iter.next();
}
}
assertEquals(Utils.mkSet(segments.segmentName(4L), segments.segmentName(5L), segments.segmentName(6L)), segmentDirs(baseDir));
}
Aggregations