use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.
the class MeteredKeyValueBytesStoreTest method shouldPutIfAbsentAndRecordPutIfAbsentMetric.
@Test
public void shouldPutIfAbsentAndRecordPutIfAbsentMetric() {
EasyMock.expect(inner.putIfAbsent(EasyMock.eq(keyBytes), EasyMock.aryEq(valueBytes))).andReturn(null);
init();
metered.putIfAbsent(key, value);
final KafkaMetric metric = metric("put-if-absent-rate");
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.
the class MeteredKeyValueBytesStoreTest method shouldGetAllFromInnerStoreAndRecordAllMetric.
@Test
public void shouldGetAllFromInnerStoreAndRecordAllMetric() {
EasyMock.expect(inner.all()).andReturn(new KeyValueIteratorStub<>(Collections.singletonList(KeyValue.pair(keyBytes, valueBytes)).iterator()));
init();
final KeyValueIterator<String, String> iterator = metered.all();
assertThat(iterator.next().value, equalTo(value));
assertFalse(iterator.hasNext());
iterator.close();
final KafkaMetric metric = metric(new MetricName("all-rate", "stream-scope-metrics", "", tags));
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method shouldRecordRestoreTimeOnInit.
@Test
public void shouldRecordRestoreTimeOnInit() {
init();
final KafkaMetric metric = metric("restore-rate");
assertTrue(metric.value() > 0);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method shouldFindSessionsFromStoreAndRecordFetchMetric.
@Test
public void shouldFindSessionsFromStoreAndRecordFetchMetric() {
EasyMock.expect(inner.findSessions(Bytes.wrap(keyBytes), 0, 0)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(windowedKeyBytes, keyBytes)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = metered.findSessions(key, 0, 0);
assertThat(iterator.next().value, equalTo(key));
assertFalse(iterator.hasNext());
iterator.close();
final KafkaMetric metric = metric("fetch-rate");
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method shouldFetchRangeFromStoreAndRecordFetchMetric.
@Test
public void shouldFetchRangeFromStoreAndRecordFetchMetric() {
EasyMock.expect(inner.findSessions(Bytes.wrap(keyBytes), Bytes.wrap(keyBytes), 0, Long.MAX_VALUE)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(windowedKeyBytes, keyBytes)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = metered.fetch(key, key);
assertThat(iterator.next().value, equalTo(key));
assertFalse(iterator.hasNext());
iterator.close();
final KafkaMetric metric = metric("fetch-rate");
assertTrue(metric.value() > 0);
EasyMock.verify(inner);
}
Aggregations