use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredWindowStoreTest method shouldBackwardFetchAllFromInnerStoreAndRecordFetchMetrics.
@Test
public void shouldBackwardFetchAllFromInnerStoreAndRecordFetchMetrics() {
expect(innerStoreMock.backwardFetchAll(1, 1)).andReturn(KeyValueIterators.emptyIterator());
replay(innerStoreMock);
store.init((StateStoreContext) context, store);
// recorded on close;
store.backwardFetchAll(ofEpochMilli(1), ofEpochMilli(1)).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");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(innerStoreMock);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredWindowStoreTest method shouldFetchFromInnerStoreAndRecordFetchMetrics.
@Test
public void shouldFetchFromInnerStoreAndRecordFetchMetrics() {
expect(innerStoreMock.fetch(Bytes.wrap("a".getBytes()), 1, 1)).andReturn(KeyValueIterators.emptyWindowStoreIterator());
replay(innerStoreMock);
store.init((StateStoreContext) context, store);
// recorded on close;
store.fetch("a", ofEpochMilli(1), ofEpochMilli(1)).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");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(innerStoreMock);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredWindowStoreTest method shouldPutToInnerStoreAndRecordPutMetrics.
@Test
public void shouldPutToInnerStoreAndRecordPutMetrics() {
final byte[] bytes = "a".getBytes();
innerStoreMock.put(eq(Bytes.wrap(bytes)), anyObject(), eq(context.timestamp()));
replay(innerStoreMock);
store.init((StateStoreContext) context, store);
store.put("a", "a", context.timestamp());
// 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");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(innerStoreMock);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredWindowStoreTest method shouldFetchRangeFromInnerStoreAndRecordFetchMetrics.
@Test
public void shouldFetchRangeFromInnerStoreAndRecordFetchMetrics() {
expect(innerStoreMock.fetch(Bytes.wrap("a".getBytes()), Bytes.wrap("b".getBytes()), 1, 1)).andReturn(KeyValueIterators.emptyIterator());
expect(innerStoreMock.fetch(null, Bytes.wrap("b".getBytes()), 1, 1)).andReturn(KeyValueIterators.emptyIterator());
expect(innerStoreMock.fetch(Bytes.wrap("a".getBytes()), null, 1, 1)).andReturn(KeyValueIterators.emptyIterator());
expect(innerStoreMock.fetch(null, null, 1, 1)).andReturn(KeyValueIterators.emptyIterator());
replay(innerStoreMock);
store.init((StateStoreContext) context, store);
// recorded on close;
store.fetch("a", "b", ofEpochMilli(1), ofEpochMilli(1)).close();
// recorded on close;
store.fetch(null, "b", ofEpochMilli(1), ofEpochMilli(1)).close();
// recorded on close;
store.fetch("a", null, ofEpochMilli(1), ofEpochMilli(1)).close();
// recorded on close;
store.fetch(null, null, ofEpochMilli(1), ofEpochMilli(1)).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");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(innerStoreMock);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredWindowStoreTest method shouldBackwardFetchFromInnerStoreAndRecordFetchMetrics.
@Test
public void shouldBackwardFetchFromInnerStoreAndRecordFetchMetrics() {
expect(innerStoreMock.backwardFetch(Bytes.wrap("a".getBytes()), Bytes.wrap("b".getBytes()), 1, 1)).andReturn(KeyValueIterators.emptyIterator());
replay(innerStoreMock);
store.init((StateStoreContext) context, store);
// recorded on close;
store.backwardFetch("a", "b", ofEpochMilli(1), ofEpochMilli(1)).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");
assertThat((Double) metric.metricValue(), greaterThan(0.0));
verify(innerStoreMock);
}
Aggregations