Search in sources :

Example 66 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class ThreadCacheTest method shouldReturnNullIfKeyIsNull.

@Test
public void shouldReturnNullIfKeyIsNull() {
    final ThreadCache threadCache = new ThreadCache(logContext, 10, new MockStreamsMetrics(new Metrics()));
    threadCache.put(namespace, Bytes.wrap(new byte[] { 1 }), cleanEntry(new byte[] { 1 }));
    assertNull(threadCache.get(namespace, null));
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Test(org.junit.Test)

Example 67 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class ThreadCacheTest method shouldNotBlowUpOnNonExistentNamespaceWhenDeleting.

@Test
public void shouldNotBlowUpOnNonExistentNamespaceWhenDeleting() {
    final ThreadCache cache = new ThreadCache(logContext, 10000L, new MockStreamsMetrics(new Metrics()));
    assertNull(cache.delete(namespace, Bytes.wrap(new byte[] { 1 })));
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Test(org.junit.Test)

Example 68 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class ThreadCacheTest method shouldNotBlowUpOnNonExistentKeyWhenDeleting.

@Test
public void shouldNotBlowUpOnNonExistentKeyWhenDeleting() {
    final Bytes key = Bytes.wrap(new byte[] { 0 });
    final ThreadCache cache = new ThreadCache(logContext, 10000L, new MockStreamsMetrics(new Metrics()));
    cache.put(namespace, key, dirtyEntry(key.get()));
    assertNull(cache.delete(namespace, Bytes.wrap(new byte[] { 1 })));
}
Also used : Bytes(org.apache.kafka.common.utils.Bytes) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Test(org.junit.Test)

Example 69 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class ThreadCacheTest method shouldNotClashWithOverlappingNames.

@Test
public void shouldNotClashWithOverlappingNames() {
    final ThreadCache cache = new ThreadCache(logContext, 10000L, new MockStreamsMetrics(new Metrics()));
    final Bytes nameByte = Bytes.wrap(new byte[] { 0 });
    final Bytes name1Byte = Bytes.wrap(new byte[] { 1 });
    cache.put(namespace1, nameByte, dirtyEntry(nameByte.get()));
    cache.put(namespace2, nameByte, dirtyEntry(name1Byte.get()));
    assertArrayEquals(nameByte.get(), cache.get(namespace1, nameByte).value);
    assertArrayEquals(name1Byte.get(), cache.get(namespace2, nameByte).value);
}
Also used : Bytes(org.apache.kafka.common.utils.Bytes) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Test(org.junit.Test)

Example 70 with MockStreamsMetrics

use of org.apache.kafka.streams.processor.internals.MockStreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class ThreadCacheTest method shouldEvictImmediatelyIfCacheSizeIsZero.

@Test
public void shouldEvictImmediatelyIfCacheSizeIsZero() {
    final ThreadCache cache = new ThreadCache(logContext, 0, new MockStreamsMetrics(new Metrics()));
    shouldEvictImmediatelyIfCacheSizeIsZeroOrVerySmall(cache);
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Metrics(org.apache.kafka.common.metrics.Metrics) MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) Test(org.junit.Test)

Aggregations

MockStreamsMetrics (org.apache.kafka.streams.processor.internals.MockStreamsMetrics)103 Metrics (org.apache.kafka.common.metrics.Metrics)101 Test (org.junit.Test)59 Before (org.junit.Before)38 LogContext (org.apache.kafka.common.utils.LogContext)32 Bytes (org.apache.kafka.common.utils.Bytes)27 ArrayList (java.util.ArrayList)17 NoOpRecordCollector (org.apache.kafka.test.NoOpRecordCollector)15 InternalMockProcessorContext (org.apache.kafka.test.InternalMockProcessorContext)14 ProcessorRecordContext (org.apache.kafka.streams.processor.internals.ProcessorRecordContext)12 MockProcessorContext (org.apache.kafka.test.MockProcessorContext)10 File (java.io.File)7 RecordHeaders (org.apache.kafka.common.header.internals.RecordHeaders)7 MockTime (org.apache.kafka.common.utils.MockTime)7 KeyValue (org.apache.kafka.streams.KeyValue)7 MockRecordCollector (org.apache.kafka.test.MockRecordCollector)7 StreamsMetricsImpl (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl)6 Properties (java.util.Properties)5 Serializer (org.apache.kafka.common.serialization.Serializer)4 StreamsConfig (org.apache.kafka.streams.StreamsConfig)4