use of org.apache.kafka.common.header.internals.RecordHeaders in project kafka by apache.
the class BufferValueTest method shouldAccountForDeduplicationInSizeEstimate.
@Test
public void shouldAccountForDeduplicationInSizeEstimate() {
final ProcessorRecordContext context = new ProcessorRecordContext(0L, 0L, 0, "topic", new RecordHeaders());
assertEquals(25L, new BufferValue(null, null, null, context).residentMemorySizeEstimate());
assertEquals(26L, new BufferValue(new byte[] { (byte) 0 }, null, null, context).residentMemorySizeEstimate());
assertEquals(26L, new BufferValue(null, new byte[] { (byte) 0 }, null, context).residentMemorySizeEstimate());
assertEquals(26L, new BufferValue(new byte[] { (byte) 0 }, new byte[] { (byte) 0 }, null, context).residentMemorySizeEstimate());
assertEquals(27L, new BufferValue(new byte[] { (byte) 0 }, new byte[] { (byte) 1 }, null, context).residentMemorySizeEstimate());
// new value should get counted, but doesn't get deduplicated
assertEquals(28L, new BufferValue(new byte[] { (byte) 0 }, new byte[] { (byte) 1 }, new byte[] { (byte) 0 }, context).residentMemorySizeEstimate());
}
use of org.apache.kafka.common.header.internals.RecordHeaders in project kafka by apache.
the class CachingPersistentSessionStoreTest method setUpCloseTests.
private void setUpCloseTests() {
underlyingStore.close();
underlyingStore = EasyMock.createNiceMock(SessionStore.class);
EasyMock.expect(underlyingStore.name()).andStubReturn("store-name");
EasyMock.expect(underlyingStore.isOpen()).andStubReturn(true);
EasyMock.replay(underlyingStore);
cachingStore = new CachingSessionStore(underlyingStore, SEGMENT_INTERVAL);
cache = EasyMock.niceMock(ThreadCache.class);
final InternalMockProcessorContext context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), null, null, null, cache);
context.setRecordContext(new ProcessorRecordContext(10, 0, 0, TOPIC, new RecordHeaders()));
cachingStore.init((StateStoreContext) context, cachingStore);
}
use of org.apache.kafka.common.header.internals.RecordHeaders in project kafka by apache.
the class CachingInMemorySessionStoreTest method setUpCloseTests.
private void setUpCloseTests() {
underlyingStore = EasyMock.createNiceMock(SessionStore.class);
EasyMock.expect(underlyingStore.name()).andStubReturn("store-name");
EasyMock.expect(underlyingStore.isOpen()).andStubReturn(true);
EasyMock.replay(underlyingStore);
cachingStore = new CachingSessionStore(underlyingStore, SEGMENT_INTERVAL);
cache = EasyMock.niceMock(ThreadCache.class);
final InternalMockProcessorContext context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), null, null, null, cache);
context.setRecordContext(new ProcessorRecordContext(10, 0, 0, TOPIC, new RecordHeaders()));
cachingStore.init((StateStoreContext) context, cachingStore);
}
use of org.apache.kafka.common.header.internals.RecordHeaders in project kafka by apache.
the class CachingInMemorySessionStoreTest method before.
@Before
public void before() {
underlyingStore = new InMemorySessionStore("store-name", Long.MAX_VALUE, "metric-scope");
cachingStore = new CachingSessionStore(underlyingStore, SEGMENT_INTERVAL);
cache = new ThreadCache(new LogContext("testCache "), MAX_CACHE_SIZE_BYTES, new MockStreamsMetrics(new Metrics()));
context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), null, null, null, cache);
context.setRecordContext(new ProcessorRecordContext(DEFAULT_TIMESTAMP, 0, 0, TOPIC, new RecordHeaders()));
cachingStore.init((StateStoreContext) context, cachingStore);
}
use of org.apache.kafka.common.header.internals.RecordHeaders in project kafka by apache.
the class CachingPersistentWindowStoreTest method setUpCloseTests.
private void setUpCloseTests() {
underlyingStore = EasyMock.createNiceMock(WindowStore.class);
EasyMock.expect(underlyingStore.name()).andStubReturn("store-name");
EasyMock.expect(underlyingStore.isOpen()).andStubReturn(true);
EasyMock.replay(underlyingStore);
cachingStore = new CachingWindowStore(underlyingStore, WINDOW_SIZE, SEGMENT_INTERVAL);
cache = EasyMock.createNiceMock(ThreadCache.class);
context = new InternalMockProcessorContext<>(TestUtils.tempDirectory(), null, null, null, cache);
context.setRecordContext(new ProcessorRecordContext(10, 0, 0, TOPIC, new RecordHeaders()));
cachingStore.init((StateStoreContext) context, cachingStore);
}
Aggregations