use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class MergedSortedCacheKeyValueBytesStoreIteratorTest method shouldPeekNextKeyReverse.
@Test
public void shouldPeekNextKeyReverse() {
final KeyValueStore<Bytes, byte[]> kv = new InMemoryKeyValueStore("one");
final ThreadCache cache = new ThreadCache(new LogContext("testCache "), 1000000L, new MockStreamsMetrics(new Metrics()));
final byte[][] bytes = { { 0 }, { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 } };
for (int i = 0; i < bytes.length - 1; i += 2) {
kv.put(Bytes.wrap(bytes[i]), bytes[i]);
cache.put(namespace, Bytes.wrap(bytes[i + 1]), new LRUCacheEntry(bytes[i + 1]));
}
final Bytes from = Bytes.wrap(new byte[] { 2 });
final Bytes to = Bytes.wrap(new byte[] { 9 });
final KeyValueIterator<Bytes, byte[]> storeIterator = kv.reverseRange(from, to);
final ThreadCache.MemoryLRUCacheBytesIterator cacheIterator = cache.reverseRange(namespace, from, to);
final MergedSortedCacheKeyValueBytesStoreIterator iterator = new MergedSortedCacheKeyValueBytesStoreIterator(cacheIterator, storeIterator, false);
final byte[][] values = new byte[8][];
int index = 0;
int bytesIndex = 9;
while (iterator.hasNext()) {
final byte[] keys = iterator.peekNextKey().get();
values[index++] = keys;
assertArrayEquals(bytes[bytesIndex--], keys);
iterator.next();
}
iterator.close();
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class MergedSortedCacheKeyValueBytesStoreIteratorTest method setUp.
@Before
public void setUp() {
store = new InMemoryKeyValueStore(namespace);
cache = new ThreadCache(new LogContext("testCache "), 10000L, new MockStreamsMetrics(new Metrics()));
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class NamedCacheTest method setUp.
@Before
public void setUp() {
final Metrics innerMetrics = new Metrics();
final StreamsMetricsImpl metrics = new MockStreamsMetrics(innerMetrics);
cache = new NamedCache("dummy-name", metrics);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class ListValueStoreTest method setup.
@Before
public void setup() {
listStore = buildStore(Serdes.Integer(), Serdes.String());
final MockRecordCollector recordCollector = new MockRecordCollector();
final InternalMockProcessorContext<Integer, String> context = new InternalMockProcessorContext<>(baseDir, Serdes.String(), Serdes.Integer(), recordCollector, new ThreadCache(new LogContext("testCache"), 0, new MockStreamsMetrics(new Metrics())));
context.setTime(1L);
listStore.init((StateStoreContext) context, listStore);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.
the class KeyValueSegmentsTest method createContext.
@Before
public void createContext() {
stateDirectory = TestUtils.tempDirectory();
context = new InternalMockProcessorContext<>(stateDirectory, Serdes.String(), Serdes.Long(), new MockRecordCollector(), new ThreadCache(new LogContext("testCache "), 0, new MockStreamsMetrics(new Metrics())));
segments = new KeyValueSegments(storeName, METRICS_SCOPE, RETENTION_PERIOD, SEGMENT_INTERVAL);
segments.openExisting(context, -1L);
}
Aggregations