Skip to content

KAFKA-7075: Allow Topology#addGlobalStore to add a window store#5725

Closed
lmontrieux wants to merge 8 commits intoapache:trunkfrom
lmontrieux:KAFKA-7075-addGlobalStore-with-window-store
Closed

KAFKA-7075: Allow Topology#addGlobalStore to add a window store#5725
lmontrieux wants to merge 8 commits intoapache:trunkfrom
lmontrieux:KAFKA-7075-addGlobalStore-with-window-store

Conversation

@lmontrieux
Copy link
Copy Markdown

@lmontrieux lmontrieux commented Oct 2, 2018

InternalTopologyBuilder#addGlobalStore has no tests for stores other than KeyValueStore. This PR adds a new unit test to show that a StoreBuilder can be used in InternalTopologyBuilder#addGlobalStore. This required creating two new mocks, MockWindowStore and MockWindowStoreBuilder, modelled on MockKeyValueStore and MockKeyValueStoreBuilder, respectively.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@lmontrieux
Copy link
Copy Markdown
Author

@guozhangwang since you reported the bug in Jira, would you like to have a look at this PR?

@lmontrieux
Copy link
Copy Markdown
Author

retest this please

@mjsax mjsax added the streams label Oct 4, 2018
Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Some comments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the cast make sense? addGlobalStore has not generic type any more and thus the type cannot be checked anyway?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you are right. The cast was useful when addGlobalStore still had a generic type, as it would refuse to compile. I should have removed it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjsax fixed it in 24f1fc3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need MockWindowStoreBuilder and MockWindowStore ? Can't we just use Mockito ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use Mockito. I went for EasyMock as there were already MockKeyValueStoreBuilder and MockKeyValueStore, so it seemed like a nice fit, at least for someone who, like me, is only getting started with the Kafka code. I since saw discussions about using Mockito instead of EasyMock on the mailing list, and I agree that it makes sense to use Mockito.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I can't seem to find any use of mockito anywhere in this repo, so perhaps it is better to stick with easymock for this PR? What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine -- it's just about avoiding own mock classes.

Copy link
Copy Markdown
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmontrieux thanks for the contribution.

In my mind, one of the reasons the addGlobalStore method accepts a KeyValueStore is Streams doesn't need to know anything about the data since the data from the backing topic is in key-value pairs already. So loading the global store is just a matter of put(key, value).

Can discuss how the loading of a windowed GlobalStore would work? Maybe provide an integration test as well?

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Oct 4, 2018

@bbejeck Note, that when adding a global store, user also provides the corresponding processor. This method is at Processor API level and it's the users responsibility to implement the Processor correctly. At DSL level, the API is still limited to accept KeyValueStore only.

Adding an integration test is always a good idea of course :)

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Oct 4, 2018

that when adding a global store, user also provides the corresponding processor.

@mjsax hhanks for the clarification. As soon as I read your comment I realized that I knew that, but it slipped my mind at the moment.

Personal confusion aside, I agree with you that an integration test is still worthwhile.

@lmontrieux
Copy link
Copy Markdown
Author

@mjsax @bbejeck thank you for your comments. I will add an integration test asap.

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Nov 19, 2018

Hi, @lmontrieux are you still working on this PR?

@lmontrieux
Copy link
Copy Markdown
Author

Hi @bbejeck ,
Sorry for the delay, life got in the way. I expect to give this PR some attention over the weekend.

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Nov 27, 2018

Hi @lmontrieux no need to apologize! Just checking in and thanks again for contributing!

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Feb 21, 2019

@lmontrieux Are you still interested in working on this?

@guozhangwang
Copy link
Copy Markdown
Contributor

Actually, looking at the latest trunk, I think the enforced types have already been resolved, but we still need this PR for adding the shouldAllowAddGlobalStoreWithNonKVStore test to cover this call path.

@lmontrieux could you rebase your PR and then only leave the test / mocks in place, and run them to see if they pass? If yes, we can go ahead and review / merge this PR still.

@lmontrieux
Copy link
Copy Markdown
Author

@guozhangwang sure, I'll do that

@guozhangwang
Copy link
Copy Markdown
Contributor

Thank you!

@lmontrieux
Copy link
Copy Markdown
Author

Wow, I did something wrong. Will fix it.

@lmontrieux lmontrieux force-pushed the KAFKA-7075-addGlobalStore-with-window-store branch from f7b368b to d92ab5f Compare February 26, 2019 20:48
@lmontrieux lmontrieux force-pushed the KAFKA-7075-addGlobalStore-with-window-store branch from d92ab5f to 37a287a Compare February 26, 2019 20:49
@lmontrieux
Copy link
Copy Markdown
Author

Some warnings are causing the build to fail, I'll have a look

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 6, 2019

@lmontrieux Any updates on this PR?

@lmontrieux
Copy link
Copy Markdown
Author

@mjsax now all tests are passing. I'll update the PR description to reflect that this only adds unit tests.

Copy link
Copy Markdown
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lmontrieux! LGTM.

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 11, 2019

\cc @mjsax for a second review

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 14, 2019

The original ticket claims, that it's not possible to add a non-kv-store as global store? This PR adds test that proof the ticket wrong? Or was it fixed with a different PR?

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Mar 14, 2019

Seems this was fixed via #5779

Should we close the ticket as "contained by" and merge this as MINOR PR instead?

@Test
public void shouldAllowAddGlobalStoreWithNonKVStore() {
final StoreBuilder windowStoreBuilder = new MockWindowStoreBuilder("store", false);
builder.addGlobalStore(windowStoreBuilder.withLoggingDisabled(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature of addGlobalStore accepts any StoreBuilder, thus I am wondering if we should switch to pass in a TestStateStoreBuilder that returns StateStore instead of a WindowedStore?

I am also thinking if we should add an test using TopologyTestDriver to verify that a TestStateStore can be used as global store?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll update the PR accordingly

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 20, 2019

Should we close the ticket as "contained by" and merge this as MINOR PR instead?

SGTM.

@lmontrieux can you respond to @mjsax's comments?

@lmontrieux
Copy link
Copy Markdown
Author

Seems this was fixed via #5779

Should we close the ticket as "contained by" and merge this as MINOR PR instead?

Yes, makes sense to me.

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Apr 17, 2019

@lmontrieux what's status of this PR? Once you address the latest comments we can get this merged. Thanks!

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Jun 1, 2019

@lmontrieux -- just cycling back to this PR. Are you still interesting? Seems the PR would need a rebase and there a some open comments to address.

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Dec 29, 2022

Closing this old PR due to inactivity.

@mjsax mjsax closed this Dec 29, 2022
@fonsdant
Copy link
Copy Markdown
Contributor

@mjsax, do you think this PR is still needed? If yes, and if @lmontrieux agrees, I could assume this work.

@mjsax
Copy link
Copy Markdown
Member

mjsax commented Jan 4, 2025

@fonsdant I am not 100% sure -- guess it should not be too hard to write a small unit test for it (or first check if one might already exist)? If the unit test passed, we know it's not an issue any longer (and we could close some testing gap).

If it's still a problem feel free to pick it up. This PR was close 2 years ago, and nobody is working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants