Search in sources :

Example 1 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.

the class CachingKeyValueStoreTest method setUp.

@Before
public void setUp() throws Exception {
    final String storeName = "store";
    underlyingStore = new InMemoryKeyValueStore<>(storeName, Serdes.Bytes(), Serdes.ByteArray());
    cacheFlushListener = new CacheFlushListenerStub<>();
    store = new CachingKeyValueStore<>(underlyingStore, Serdes.String(), Serdes.String());
    store.setFlushListener(cacheFlushListener);
    cache = new ThreadCache("testCache", maxCacheSizeBytes, new MockStreamsMetrics(new Metrics()));
    final MockProcessorContext context = new MockProcessorContext(null, null, null, (RecordCollector) null, cache);
    topic = "topic";
    context.setRecordContext(new ProcessorRecordContext(10, 0, 0, topic));
    store.init(context, null);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) ProcessorRecordContext(org.apache.kafka.streams.processor.internals.ProcessorRecordContext) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Before(org.junit.Before)

Example 2 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.

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);
        }
    };
    final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), collector, new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
    context.setTime(0);
    store.init(context, store);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Serializer(org.apache.kafka.common.serialization.Serializer) Before(org.junit.Before)

Example 3 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.

the class ChangeLoggingKeyValueStoreTest 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);
        }
    };
    final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), collector, new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
    context.setTime(0);
    store.init(context, store);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Serializer(org.apache.kafka.common.serialization.Serializer) Before(org.junit.Before)

Example 4 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.

the class SegmentsTest method createContext.

@Before
public void createContext() {
    context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
    segments = new Segments("test", 4 * 60 * 1000, NUM_SEGMENTS);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Before(org.junit.Before)

Example 5 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project kafka by apache.

the class RocksDBSegmentedBytesStoreTest method before.

@Before
public void before() {
    bytesStore = new RocksDBSegmentedBytesStore(storeName, retention, numSegments, new SessionKeySchema());
    stateDir = TestUtils.tempDirectory();
    final MockProcessorContext context = new MockProcessorContext(stateDir, Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
    bytesStore.init(context, bytesStore);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Before(org.junit.Before)

Aggregations

MockStreamsMetrics (org.apache.kafka.streams.processor.internals.MockStreamsMetrics)103 Metrics (org.apache.kafka.common.metrics.Metrics)101 Test (org.junit.Test)59 Before (org.junit.Before)38 LogContext (org.apache.kafka.common.utils.LogContext)32 Bytes (org.apache.kafka.common.utils.Bytes)27 ArrayList (java.util.ArrayList)17 NoOpRecordCollector (org.apache.kafka.test.NoOpRecordCollector)15 InternalMockProcessorContext (org.apache.kafka.test.InternalMockProcessorContext)14 ProcessorRecordContext (org.apache.kafka.streams.processor.internals.ProcessorRecordContext)12 MockProcessorContext (org.apache.kafka.test.MockProcessorContext)10 File (java.io.File)7 RecordHeaders (org.apache.kafka.common.header.internals.RecordHeaders)7 MockTime (org.apache.kafka.common.utils.MockTime)7 KeyValue (org.apache.kafka.streams.KeyValue)7 MockRecordCollector (org.apache.kafka.test.MockRecordCollector)7 StreamsMetricsImpl (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl)6 Properties (java.util.Properties)5 Serializer (org.apache.kafka.common.serialization.Serializer)4 StreamsConfig (org.apache.kafka.streams.StreamsConfig)4