use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldGetAllFromInnerStoreAndRecordAllMetric.
@Test
public void shouldGetAllFromInnerStoreAndRecordAllMetric() {
expect(inner.all()).andReturn(new KeyValueIteratorStub<>(Collections.singletonList(BYTE_KEY_VALUE_PAIR).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", STORE_LEVEL_GROUP, "", tags));
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldGetRecordsWithPrefixKey.
@Test
public void shouldGetRecordsWithPrefixKey() {
final StringSerializer stringSerializer = new StringSerializer();
expect(inner.prefixScan(KEY, stringSerializer)).andReturn(new KeyValueIteratorStub<>(Collections.singletonList(BYTE_KEY_VALUE_PAIR).iterator()));
init();
final KeyValueIterator<String, String> iterator = metered.prefixScan(KEY, stringSerializer);
assertThat(iterator.next().value, equalTo(VALUE));
iterator.close();
final KafkaMetric metric = metrics.metric(new MetricName("prefix-scan-rate", STORE_LEVEL_GROUP, "", tags));
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredSessionStoreTest method shouldFetchForKeyAndRecordFetchMetric.
@Test
public void shouldFetchForKeyAndRecordFetchMetric() {
expect(innerStore.fetch(KEY_BYTES)).andReturn(new KeyValueIteratorStub<>(Collections.singleton(KeyValue.pair(WINDOWED_KEY_BYTES, VALUE_BYTES)).iterator()));
init();
final KeyValueIterator<Windowed<String>, String> iterator = store.fetch(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 shouldWriteBytesToInnerStoreAndRecordPutMetric.
@Test
public void shouldWriteBytesToInnerStoreAndRecordPutMetric() {
innerStore.put(eq(WINDOWED_KEY_BYTES), aryEq(VALUE_BYTES));
expectLastCall();
init();
store.put(WINDOWED_KEY, VALUE);
// it suffices to verify one put metric since all put metrics are recorded by the same sensor
// and the sensor is tested elsewhere
final KafkaMetric metric = metric("put-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 shouldFetchRangeFromStoreAndRecordFetchMetric.
@Test
public void shouldFetchRangeFromStoreAndRecordFetchMetric() {
expect(innerStore.fetch(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.fetch(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);
}
Aggregations