KAFKA-3522: Add internal RecordConverter interface#6150
Conversation
|
Call for review @guozhangwang @bbejeck @vvcephei |
| final StateStore stateStore = | ||
| store instanceof WrappedStateStore ? ((WrappedStateStore) store).inner() : store; | ||
| final RecordConverter recordConverter = | ||
| stateStore instanceof RecordConverter ? (RecordConverter) stateStore : new DefaultRecordConverter(); |
There was a problem hiding this comment.
Stores can implement the RecordConverter interface -- if they don't do, we use default no-op converter that maps from key-value to key-value.
| final StateStore stateStore = | ||
| store instanceof WrappedStateStore ? ((WrappedStateStore) store).inner() : store; | ||
| final RecordConverter recordConverter = | ||
| stateStore instanceof RecordConverter ? (RecordConverter) stateStore : new DefaultRecordConverter(); |
There was a problem hiding this comment.
Stores can implement the RecordConverter interface -- if they don't do, we use default no-op converter that maps from key-value to key-value.
| /** | ||
| * {@code RecordConverter} translates a {@link ConsumerRecord} into a {@link KeyValue} pair. | ||
| */ | ||
| // TODO: move this class to public API |
There was a problem hiding this comment.
After the KIP is accepted, this interface will become part of public API.
| log.trace("Restoring state store {} from changelog topic {}", storeName, topic); | ||
|
|
||
| final StateStore stateStore = | ||
| store instanceof WrappedStateStore ? ((WrappedStateStore) store).inner() : store; |
There was a problem hiding this comment.
We should update the tests for setting the stateStore and recordConverter
There was a problem hiding this comment.
I was able to add a test for GlobalStateManagerImpl -- also discovered a gap while trying to add a test for ProcessorStateManagerImpl: updating standby tasks was not covered by the converter -- added a test for this case.
However, I am not sure how I can test the converter for ProcessorStateManagerImpl restore case, because the ProcessorStateManagerImpl does not use the converter, but by the TaskManager -- however, it would be weird to test test in the TaskManagerTest because it has nothing to do with the task manager.
Thoughts?
I'll add some upgrade integration tests later, that will cover this case. Not sure if this would be sufficient?
|
test failures retest this please |
guozhangwang
left a comment
There was a problem hiding this comment.
Two meta comments:
- could we run the simple benchmark and see if there's any significant perf impact?
- Could we add more test case to ProcessorStateManager / GlobalStateManagerTest to verify that the default / customized converter is used?
| public void shouldThrowIllegalArgumentExceptionIfAttemptingToRegisterStoreTwice() { | ||
| stateManager.initialize(); | ||
| initializeConsumer(2, 1, t1); | ||
| initializeConsumer(2, 0, t1); |
There was a problem hiding this comment.
This is "fix" on the side -- initializeConsumer did some weird stuff.
|
Updated this. |
This test passed locally. Might be a race condition. We should monitor this. \cc @guozhangwang @bbejeck @vvcephei @ableegoldman Retest this please |
guozhangwang
left a comment
There was a problem hiding this comment.
LGTM. If you've verified no observable perf difference please feel free to merge
|
Triggered
Let's see :) |
|
Test failures in |
|
Move |
|
Retest this please |
Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <guozhang@confluent.io>
* ak/trunk: MINOR: fix race condition in KafkaStreamsTest (apache#6185) KAFKA-4850: Enable bloomfilters (apache#6012) MINOR: ducker-ak: add down -f, avoid using a terminal in ducker test KAFKA-5117: Stop resolving externalized configs in Connect REST API MINOR: Cleanup handling of mixed transactional/idempotent records (apache#6172) KAFKA-7844: Use regular subproject for generator to fix *All targets (apache#6182) Fix Documentation for cleanup.policy is out of date (apache#6181) MINOR: increase timeouts for KafkaStreamsTest (apache#6178) MINOR: Rejoin split ssl principal mapping rules (apache#6099) MINOR: Handle case where connector status endpoints returns 404 (apache#6176) MINOR: Remove unused imports, exceptions, and values (apache#6117) KAFKA-3522: Add internal RecordConverter interface (apache#6150) Fix Javadoc of KafkaConsumer (apache#6155) KAFKA-6455: Extend CacheFlushListener to forward timestamp (apache#6147) MINOR: Log partition info when creating new request batch in controller (apache#6145) KAFKA-7652: Part I; Fix SessionStore's findSession(single-key) (apache#6134) MINOR: Remove the InvalidTopicException handling in InternalTopicManager (apache#6167) [KAFKA-7024] Rocksdb state directory should be created before opening the DB (apache#6138) MINOR:: Fix typos (apache#6079)
Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <guozhang@confluent.io>
Part of KIP-258.
Adding the proposed
RecordConverterinterface.The
RecordConverteris responsible to convertConsumerRecordsfrom a changelog topic into<byte[], byte[]>key-value-pairs that are put into the stores. This is required to move the timestamp from theConsumerRecordinto the value-part in the store. The default implementation only maps key-value to key-value, ie, it's a no-op and this PR does not change any behavior.