use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.
the class NamedCacheTest method setUp.
@Before
public void setUp() {
streamMetrics = new MockStreamsMetrics(new Metrics());
cache = new NamedCache(taskIDString + "-" + underlyingStoreName, streamMetrics);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.
the class KStreamTestDriver method setUp.
public void setUp(final StreamsBuilder builder, final File stateDir, final Serde<?> keySerde, final Serde<?> valSerde, final long cacheSize) {
final InternalTopologyBuilder internalTopologyBuilder = StreamsBuilderTest.internalTopologyBuilder(builder);
internalTopologyBuilder.setApplicationId("TestDriver");
topology = internalTopologyBuilder.build(null);
globalTopology = internalTopologyBuilder.buildGlobalStateTopology();
final ThreadCache cache = new ThreadCache(logContext, cacheSize, new MockStreamsMetrics(new Metrics()));
context = new InternalMockProcessorContext(stateDir, keySerde, valSerde, new MockRecordCollector(), cache);
context.setRecordContext(new ProcessorRecordContext(0, 0, 0, "topic"));
// store map that are required for joins etc.
if (globalTopology != null) {
initTopology(globalTopology, globalTopology.globalStateStores());
}
initTopology(topology, topology.stateStores());
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.
the class CachingSessionStoreTest method setUp.
@Before
public void setUp() {
final SessionKeySchema schema = new SessionKeySchema();
schema.init("topic");
final int retention = 60000;
final int numSegments = 3;
underlying = new RocksDBSegmentedBytesStore("test", retention, numSegments, schema);
final RocksDBSessionStore<Bytes, byte[]> sessionStore = new RocksDBSessionStore<>(underlying, Serdes.Bytes(), Serdes.ByteArray());
cachingStore = new CachingSessionStore<>(sessionStore, Serdes.String(), Serdes.String(), Segments.segmentInterval(retention, numSegments));
cache = new ThreadCache(new LogContext("testCache "), MAX_CACHE_SIZE_BYTES, new MockStreamsMetrics(new Metrics()));
context = new InternalMockProcessorContext(TestUtils.tempDirectory(), null, null, null, cache);
context.setRecordContext(new ProcessorRecordContext(DEFAULT_TIMESTAMP, 0, 0, "topic"));
cachingStore.init(context, cachingStore);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.
the class CachingWindowStoreTest method setUp.
@Before
public void setUp() {
keySchema = new WindowKeySchema();
final int retention = 30000;
final int numSegments = 3;
underlying = new RocksDBSegmentedBytesStore("test", retention, numSegments, keySchema);
final RocksDBWindowStore<Bytes, byte[]> windowStore = new RocksDBWindowStore<>(underlying, Serdes.Bytes(), Serdes.ByteArray(), false, WINDOW_SIZE);
cacheListener = new CachingKeyValueStoreTest.CacheFlushListenerStub<>();
cachingStore = new CachingWindowStore<>(windowStore, Serdes.String(), Serdes.String(), WINDOW_SIZE, Segments.segmentInterval(retention, numSegments));
cachingStore.setFlushListener(cacheListener, false);
cache = new ThreadCache(new LogContext("testCache "), MAX_CACHE_SIZE_BYTES, new MockStreamsMetrics(new Metrics()));
topic = "topic";
context = new InternalMockProcessorContext(TestUtils.tempDirectory(), null, null, (RecordCollector) null, cache);
context.setRecordContext(new ProcessorRecordContext(DEFAULT_TIMESTAMP, 0, 0, topic));
cachingStore.init(context, cachingStore);
}
use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.
the class ChangeLoggingKeyValueBytesStoreTest method before.
@Before
public void before() {
final NoOpRecordCollector collector = new NoOpRecordCollector() {
@Override
public <K, V> void send(final String topic, K key, V value, Integer partition, Long timestamp, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
sent.put(key, value);
}
};
context = new InternalMockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), collector, new ThreadCache(new LogContext("testCache "), 0, new MockStreamsMetrics(new Metrics())));
context.setTime(0);
store.init(context, store);
}
Aggregations