Search in sources :

Example 21 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class MeteredWindowStoreTest method setUp.

@Before
public void setUp() throws Exception {
    final Metrics metrics = new Metrics();
    final StreamsMetrics streamsMetrics = new StreamsMetrics() {

        @Override
        public Map<MetricName, ? extends Metric> metrics() {
            return Collections.unmodifiableMap(metrics.metrics());
        }

        @Override
        public Sensor addLatencyAndThroughputSensor(String scopeName, String entityName, String operationName, Sensor.RecordingLevel recordLevel, String... tags) {
            return metrics.sensor(operationName);
        }

        @Override
        public void recordLatency(final Sensor sensor, final long startNs, final long endNs) {
            latencyRecorded.add(sensor.name());
        }

        @Override
        public Sensor addThroughputSensor(String scopeName, String entityName, String operationName, Sensor.RecordingLevel recordLevel, String... tags) {
            return metrics.sensor(operationName);
        }

        @Override
        public void recordThroughput(Sensor sensor, long value) {
            throughputRecorded.add(sensor.name());
        }

        @Override
        public void removeSensor(Sensor sensor) {
            metrics.removeSensor(sensor.name());
        }

        @Override
        public Sensor addSensor(String name, Sensor.RecordingLevel recordLevel) {
            return metrics.sensor(name);
        }

        @Override
        public Sensor addSensor(String name, Sensor.RecordingLevel recordLevel, Sensor... parents) {
            return metrics.sensor(name);
        }
    };
    context = new InternalMockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache(new LogContext("testCache "), 0, streamsMetrics)) {

        @Override
        public StreamsMetrics metrics() {
            return streamsMetrics;
        }
    };
    EasyMock.expect(innerStoreMock.name()).andReturn("store").anyTimes();
}
Also used : MetricName(org.apache.kafka.common.MetricName) Metrics(org.apache.kafka.common.metrics.Metrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) LogContext(org.apache.kafka.common.utils.LogContext) InternalMockProcessorContext(org.apache.kafka.test.InternalMockProcessorContext) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Sensor(org.apache.kafka.common.metrics.Sensor) Before(org.junit.Before)

Aggregations

StreamsMetrics (org.apache.kafka.streams.StreamsMetrics)21 Test (org.junit.Test)19 MockStreamsMetrics (org.apache.kafka.streams.processor.internals.MockStreamsMetrics)16 Metrics (org.apache.kafka.common.metrics.Metrics)5 NoOpRecordCollector (org.apache.kafka.test.NoOpRecordCollector)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 MetricName (org.apache.kafka.common.MetricName)2 Sensor (org.apache.kafka.common.metrics.Sensor)2 LogContext (org.apache.kafka.common.utils.LogContext)2 Before (org.junit.Before)2 File (java.io.File)1 PartitionInfo (org.apache.kafka.common.PartitionInfo)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 MockTime (org.apache.kafka.common.utils.MockTime)1 StreamsConfig (org.apache.kafka.streams.StreamsConfig)1 ProductionExceptionHandler (org.apache.kafka.streams.errors.ProductionExceptionHandler)1 ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)1 StateStore (org.apache.kafka.streams.processor.StateStore)1 TaskId (org.apache.kafka.streams.processor.TaskId)1 InMemoryKeyValueStore (org.apache.kafka.streams.state.internals.InMemoryKeyValueStore)1