KAFKA-7918: Inline generic parameters Pt. I: in-memory key-value store#6293
KAFKA-7918: Inline generic parameters Pt. I: in-memory key-value store#6293guozhangwang merged 4 commits intoapache:trunkfrom
Conversation
There was a problem hiding this comment.
I felt it was reasonable here to simply wrap a plain old Map with the required functionality, rather than take advantage of the KeyValueBytesStoreWrapper used elsewhere. This was largely to avoid having to write serdes for LRUCacheEntry, but if anyone feels strongly about it this test can be reworked to follow the others.
There was a problem hiding this comment.
I think it's perfectly reasonable (and preferable) to use a simple map store so that we can more effectively isolate our testing concerns.
The only thing I'd add is that, even though it wasn't the intent of these other tests to exercise the bytes store, they did. So, we should make sure that the bytes store still has full coverage after these changes.
There was a problem hiding this comment.
For this specific test though, FilteredCacheIterator is only for the caching layer not for the underlying (in-memory) store layer.
There was a problem hiding this comment.
I felt this was useful enough to pull out into a separate class, but perhaps this isn't the right place for it?
There was a problem hiding this comment.
It seems fine to me, although a more descriptive name wouldn't hurt.
There was a problem hiding this comment.
nit: we usually put such test util classes in src/test/o/a/k/test and packaged as o.a.k.test.
There was a problem hiding this comment.
Serialization isn't done in the most efficient way, but within the scope of this test is quite sufficient.
vvcephei
left a comment
There was a problem hiding this comment.
Thanks for the PR!
The change LGTM. The only concern I had was about the testing code. I'm wondering if we can eschew the new serialization wrapper store and just use your simpler KeyValueStoreWrapper implementation in the tests.
There was a problem hiding this comment.
Would it be possible to re-write the test not to need the set serde?
IIUC, the objective is just to make sure the reduce processor invokes add/subtract properly. Previously, it was convenient to use a Set to define this logic, but it's not so convenient anymore.
I don't have a problem with your implementation, it just seems like a huge chunk of code to do something we don't strictly need to do.
Alternatively, I just saw your KeyValueStoreWrapper below. You could make that store implementation available for all the tests that don't really need to test the bytes store logic. I think I'd prefer this approach.
There was a problem hiding this comment.
I'd agree, adding a StringSetSerde seems like an overkill here to me. I'd suggest we just use String as value, and reduce function like v1+v2 (there are already some mock reducers in o.a.k.test) to separate the two values for easier validation.
There was a problem hiding this comment.
If we extend the KeyValueStoreWrapper idea and extract it for use by all the tests we basically end up with a copy of the old generic InMemoryKeyValueStore, that we use just for testing. Maybe that is actually the cleanest way to do things given how different tests were relying on it for different things..?
There was a problem hiding this comment.
Personally, I think it is cleaner, since tests like this one get to focus more on the logic under test (the processor) and less on managing the state store layers just right, which should be the responsibility of other tests.
There was a problem hiding this comment.
I also agree on the StringSetSerde is a little heavyweight.
There was a problem hiding this comment.
I think it's perfectly reasonable (and preferable) to use a simple map store so that we can more effectively isolate our testing concerns.
The only thing I'd add is that, even though it wasn't the intent of these other tests to exercise the bytes store, they did. So, we should make sure that the bytes store still has full coverage after these changes.
There was a problem hiding this comment.
I think I'd recommend renaming this to something more accurate (i.e., it's not a store wrapper), and elevating it to its own class so it's available for other tests.
There was a problem hiding this comment.
Do we need it for other tests? Seems to be very specific. I would rather make it private.
There was a problem hiding this comment.
👍 Either way. In another comment, I pointed out that other tests could be simplified by using this class instead of implementing a special serde and using the bytes store. In that case, it would be used by other tests and would need to be in its own class.
But, yes, if it stays in this test only, then it should be private.
There was a problem hiding this comment.
It seems fine to me, although a more descriptive name wouldn't hurt.
guozhangwang
left a comment
There was a problem hiding this comment.
Left some very minor comments. Otherwise LGTM!
There was a problem hiding this comment.
nit: we usually put such test util classes in src/test/o/a/k/test and packaged as o.a.k.test.
There was a problem hiding this comment.
I'd agree, adding a StringSetSerde seems like an overkill here to me. I'd suggest we just use String as value, and reduce function like v1+v2 (there are already some mock reducers in o.a.k.test) to separate the two values for easier validation.
There was a problem hiding this comment.
For this specific test though, FilteredCacheIterator is only for the caching layer not for the underlying (in-memory) store layer.
mjsax
left a comment
There was a problem hiding this comment.
Thanks for the PR. Overall LGTM. Just some minor comments.
There was a problem hiding this comment.
Do we need it for other tests? Seems to be very specific. I would rather make it private.
There was a problem hiding this comment.
nit: break too long line into one parameter per line
There was a problem hiding this comment.
nit: we should call this wrapped (to unify our naming in the code base).
There was a problem hiding this comment.
we should call stringSerde.close() and intSerde.close() here (in case we don't remove this code anyway)
There was a problem hiding this comment.
nit: use { } (preferred code style for all blocks.
There was a problem hiding this comment.
We should call stringSerde.configure(...) and intSerde.configure(...) here (in case we don't remove this code anyway)
|
retest this please |
bbejeck
left a comment
There was a problem hiding this comment.
Sorry for the late review, just one minor comment otherwise LGTM.
There was a problem hiding this comment.
I also agree on the StringSetSerde is a little heavyweight.
|
Failures are related. Since the |
…ed any tests relying on using generic parameters
2574960 to
ea571b9
Compare
guozhangwang
left a comment
There was a problem hiding this comment.
The current PR lgtm.
Regarding @bbejeck 's final comment about the packaging, I had a discussion with @ableegoldman and we think that a better way to keep code clean and also have small future updates is to modify the shouldStoreAndReturnStateStores test itself tot use a bytes inmemory store. And after we have KAFKA-6460 that we will have in the public APIs for those mock stores, we can then remove this class (the test-util mocks should be quite similar to this one) and let all its callers access that one.
…InMemoryKeyValueStore from a storeBuilder
|
retest this please |
|
Merged to trunk, thanks @ableegoldman ! |
* AK/trunk: (36 commits) KAFKA-7962: Avoid NPE for StickyAssignor (apache#6308) Address flakiness of CustomQuotaCallbackTest#testCustomQuotaCallback (apache#6330) KAFKA-7918: Inline generic parameters Pt. II: RocksDB Bytes Store and Memory LRU Caches (apache#6327) MINOR: fix parameter naming (apache#6316) KAFKA-7956 In ShutdownableThread, immediately complete the shutdown if the thread has not been started (apache#6218) MINOR: Refactor replica log dir fetching for improved logging (apache#6313) [TRIVIAL] Remove unused StreamsGraphNode#repartitionRequired (apache#6227) MINOR: Increase produce timeout to 120 seconds (apache#6326) KAFKA-7918: Inline generic parameters Pt. I: in-memory key-value store (apache#6293) MINOR: Fix line break issue in upgrade notes (apache#6320) KAFKA-7972: Use automatic RPC generation in SaslHandshake MINOR: Enable capture of full stack trace in StreamTask#process (apache#6310) KAFKA-7938: Fix test flakiness in DeleteConsumerGroupsTest (apache#6312) KAFKA-7937: Fix Flaky Test ResetConsumerGroupOffsetTest.testResetOffsetsNotExistingGroup (apache#6311) MINOR: Update docs to say 2.2 (apache#6315) KAFKA-7672 : force write checkpoint during StreamTask #suspend (apache#6115) KAFKA-7961; Ignore assignment for un-subscribed partitions (apache#6304) KAFKA-7672: Restoring tasks need to be closed upon task suspension (apache#6113) KAFKA-7864; validate partitions are 0-based (apache#6246) KAFKA-7492 : Updated javadocs for aggregate and reduce methods returning null behavior. (apache#6285) ...
apache#6293) First PR in series to inline the generic parameters of the following bytes stores: [x] InMemoryKeyValueStore [ ] RocksDBWindowStore [ ] RocksDBSessionStore [ ] MemoryLRUCache [ ] MemoryNavigableLRUCache [ ] (awaiting merge) InMemoryWindowStore A number of tests took advantage of the generic InMemoryKeyValueStore and had to be reworked somewhat -- this PR covers everything related to the in-memory key-value store. Reviewers: Guozhang Wang <wangguoz@gmail.com>, Matthias J. Sax <mjsax@apache.org>, John Roesler <john@confluent.io>, Bill Bejeck <bbejeck@gmail.com>
First PR in series to inline the generic parameters of the following bytes stores:
[x] InMemoryKeyValueStore
[ ] RocksDBWindowStore
[ ] RocksDBSessionStore
[ ] MemoryLRUCache
[ ] MemoryNavigableLRUCache
[ ] (awaiting merge) InMemoryWindowStore
A number of tests took advantage of the generic InMemoryKeyValueStore and had to be reworked somewhat -- this PR covers everything related to the in-memory key-value store.
Committer Checklist (excluded from commit message)