use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class ThreadCacheTest method shouldEvictImmediatelyIfCacheSizeIsVerySmall.
@Test
public void shouldEvictImmediatelyIfCacheSizeIsVerySmall() {
final ThreadCache cache = new ThreadCache(logContext, 1, new MockStreamsMetrics(new Metrics()));
shouldEvictImmediatelyIfCacheSizeIsZeroOrVerySmall(cache);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class ThreadCacheTest method shouldNotBlowUpOnNonExistentKeyWhenDeleting.
@Test
public void shouldNotBlowUpOnNonExistentKeyWhenDeleting() {
final Bytes key = Bytes.wrap(new byte[] { 0 });
final ThreadCache cache = new ThreadCache(logContext, 10000L, new MockStreamsMetrics(new Metrics()));
cache.put(namespace, key, dirtyEntry(key.get()));
assertNull(cache.delete(namespace, Bytes.wrap(new byte[] { 1 })));
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class ThreadCacheTest method shouldNotFlushAfterDelete.
@Test
public void shouldNotFlushAfterDelete() {
final Bytes key = Bytes.wrap(new byte[] { 0 });
final ThreadCache cache = new ThreadCache(logContext, 10000L, new MockStreamsMetrics(new Metrics()));
final List<ThreadCache.DirtyEntry> received = new ArrayList<>();
cache.addDirtyEntryFlushListener(namespace, received::addAll);
cache.put(namespace, key, dirtyEntry(key.get()));
assertEquals(key.get(), cache.delete(namespace, key).value());
// flushing should have no further effect
cache.flush(namespace);
assertEquals(0, received.size());
assertEquals(cache.flushes(), 1);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class AbstractSessionBytesStoreTest method setUp.
@Before
public void setUp() {
sessionStore = buildSessionStore(RETENTION_PERIOD, Serdes.String(), Serdes.Long());
recordCollector = new MockRecordCollector();
context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), recordCollector, new ThreadCache(new LogContext("testCache"), 0, new MockStreamsMetrics(new Metrics())));
context.setTime(1L);
sessionStore.init((StateStoreContext) context, sessionStore);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class AbstractRocksDBSegmentedBytesStoreTest method before.
@Before
public void before() {
if (schema instanceof SessionKeySchema) {
windows[0] = new SessionWindow(10L, 10L);
windows[1] = new SessionWindow(500L, 1000L);
windows[2] = new SessionWindow(1_000L, 1_500L);
windows[3] = new SessionWindow(30_000L, 60_000L);
// All four of the previous windows will go into segment 1.
// The nextSegmentWindow is computed be a high enough time that when it gets written
// to the segment store, it will advance stream time past the first segment's retention time and
// expire it.
nextSegmentWindow = new SessionWindow(segmentInterval + retention, segmentInterval + retention);
}
if (schema instanceof WindowKeySchema) {
windows[0] = timeWindowForSize(10L, windowSizeForTimeWindow);
windows[1] = timeWindowForSize(500L, windowSizeForTimeWindow);
windows[2] = timeWindowForSize(1_000L, windowSizeForTimeWindow);
windows[3] = timeWindowForSize(60_000L, windowSizeForTimeWindow);
// All four of the previous windows will go into segment 1.
// The nextSegmentWindow is computed be a high enough time that when it gets written
// to the segment store, it will advance stream time past the first segment's retention time and
// expire it.
nextSegmentWindow = timeWindowForSize(segmentInterval + retention, windowSizeForTimeWindow);
}
bytesStore = getBytesStore();
stateDir = TestUtils.tempDirectory();
context = new InternalMockProcessorContext<>(stateDir, Serdes.String(), Serdes.Long(), new MockRecordCollector(), new ThreadCache(new LogContext("testCache "), 0, new MockStreamsMetrics(new Metrics())));
bytesStore.init((StateStoreContext) context, bytesStore);
}
Aggregations