use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldDeleteFromInnerStoreAndRecordDeleteMetric.
@Test
public void shouldDeleteFromInnerStoreAndRecordDeleteMetric() {
expect(inner.delete(KEY_BYTES)).andReturn(VALUE_BYTES);
init();
metered.delete(KEY);
final KafkaMetric metric = metric("delete-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldRecordRestoreLatencyOnInit.
@Test
public void shouldRecordRestoreLatencyOnInit() {
inner.init((StateStoreContext) context, metered);
init();
// it suffices to verify one restore metric since all restore metrics are recorded by the same sensor
// and the sensor is tested elsewhere
final KafkaMetric metric = metric("restore-rate");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredSessionStoreTest method shouldFindSessionRangeFromStoreAndRecordFetchMetric.
@Test
public void shouldFindSessionRangeFromStoreAndRecordFetchMetric() {
expect(innerStore.findSessions(KEY_BYTES, KEY_BYTES, 0, 0)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(WINDOWED_KEY_BYTES, VALUE_BYTES)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = store.findSessions(KEY, KEY, 0, 0);
assertThat(iterator.next().value, equalTo(VALUE));
assertFalse(iterator.hasNext());
iterator.close();
// it suffices to verify one fetch metric since all put metrics are recorded by the same sensor
// and the sensor is tested elsewhere
final KafkaMetric metric = metric("fetch-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(innerStore);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredSessionStoreTest method shouldBackwardFetchRangeFromStoreAndRecordFetchMetric.
@Test
public void shouldBackwardFetchRangeFromStoreAndRecordFetchMetric() {
expect(innerStore.backwardFetch(KEY_BYTES, KEY_BYTES)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(WINDOWED_KEY_BYTES, VALUE_BYTES)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = store.backwardFetch(KEY, KEY);
assertThat(iterator.next().value, equalTo(VALUE));
assertFalse(iterator.hasNext());
iterator.close();
// it suffices to verify one fetch metric since all fetch metrics are recorded by the same sensor
// and the sensor is tested elsewhere
final KafkaMetric metric = metric("fetch-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(innerStore);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredSessionStoreTest method shouldFindSessionsFromStoreAndRecordFetchMetric.
@Test
public void shouldFindSessionsFromStoreAndRecordFetchMetric() {
expect(innerStore.findSessions(KEY_BYTES, 0, 0)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(WINDOWED_KEY_BYTES, VALUE_BYTES)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = store.findSessions(KEY, 0, 0);
assertThat(iterator.next().value, equalTo(VALUE));
assertFalse(iterator.hasNext());
iterator.close();
// it suffices to verify one fetch metric since all put metrics are recorded by the same sensor
// and the sensor is tested elsewhere
final KafkaMetric metric = metric("fetch-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(innerStore);
}
Aggregations