use of org.apache.kafka.common.metrics.Metrics in project kafka by apache.
the class CachingKeyValueStoreTest method setUp.
@Before
public void setUp() throws Exception {
final String storeName = "store";
underlyingStore = new InMemoryKeyValueStore<>(storeName, Serdes.Bytes(), Serdes.ByteArray());
cacheFlushListener = new CacheFlushListenerStub<>();
store = new CachingKeyValueStore<>(underlyingStore, Serdes.String(), Serdes.String());
store.setFlushListener(cacheFlushListener);
cache = new ThreadCache("testCache", maxCacheSizeBytes, new MockStreamsMetrics(new Metrics()));
final MockProcessorContext context = new MockProcessorContext(null, null, null, (RecordCollector) null, cache);
topic = "topic";
context.setRecordContext(new ProcessorRecordContext(10, 0, 0, topic));
store.init(context, null);
}
use of org.apache.kafka.common.metrics.Metrics in project kafka by apache.
the class StreamsMetricsImplTest method testLatencyMetrics.
@Test
public void testLatencyMetrics() {
String groupName = "doesNotMatter";
String scope = "scope";
String entity = "entity";
String operation = "put";
Map<String, String> tags = new HashMap<>();
StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(new Metrics(), groupName, tags);
Sensor sensor1 = streamsMetrics.addLatencyAndThroughputSensor(scope, entity, operation, Sensor.RecordingLevel.DEBUG);
Map<MetricName, ? extends Metric> metrics = streamsMetrics.metrics();
// 6 metrics plus a common metric that keeps track of total registered metrics in Metrics() constructor
assertEquals(metrics.size(), 7);
streamsMetrics.removeSensor(sensor1);
metrics = streamsMetrics.metrics();
assertEquals(metrics.size(), 1);
}
use of org.apache.kafka.common.metrics.Metrics in project kafka by apache.
the class ThreadCacheTest method shouldDelete.
@Test
public void shouldDelete() throws Exception {
final ThreadCache cache = new ThreadCache("testCache", 10000L, new MockStreamsMetrics(new Metrics()));
final Bytes key = Bytes.wrap(new byte[] { 0 });
cache.put("name", key, dirtyEntry(key.get()));
assertEquals(key.get(), cache.delete("name", key).value);
assertNull(cache.get("name", key));
}
use of org.apache.kafka.common.metrics.Metrics in project kafka by apache.
the class ThreadCacheTest method shouldNotBlowUpOnNonExistentNamespaceWhenDeleting.
@Test
public void shouldNotBlowUpOnNonExistentNamespaceWhenDeleting() throws Exception {
final ThreadCache cache = new ThreadCache("testCache", 10000L, new MockStreamsMetrics(new Metrics()));
assertNull(cache.delete("name", Bytes.wrap(new byte[] { 1 })));
}
use of org.apache.kafka.common.metrics.Metrics in project kafka by apache.
the class ChangeLoggingKeyValueBytesStoreTest method before.
@Before
public void before() {
final NoOpRecordCollector collector = new NoOpRecordCollector() {
@Override
public <K, V> void send(final String topic, K key, V value, Integer partition, Long timestamp, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
sent.put(key, value);
}
};
final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), collector, new ThreadCache("testCache", 0, new MockStreamsMetrics(new Metrics())));
context.setTime(0);
store.init(context, store);
}
Aggregations