Skip to content

KAFKA-7551:Refactor to create producer & consumer in the worker. - #5842

Closed
mageshn wants to merge 6 commits into
apache:trunkfrom
mageshn:KAFKA-7551
Closed

KAFKA-7551:Refactor to create producer & consumer in the worker.#5842
mageshn wants to merge 6 commits into
apache:trunkfrom
mageshn:KAFKA-7551

Conversation

@mageshn

@mageshn mageshn commented Oct 25, 2018

Copy link
Copy Markdown
Contributor

This is minor refactoring that brings in the creation of producer and consumer to the Worker. Currently, the consumer is created in the WorkerSinkTask. This should not affect any functionality and it just makes the code structure easier to understand.

Committer Checklist (excluded from commit message)

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

@ryannedolan ryannedolan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

makes sense to me!

@mageshn

mageshn commented Oct 26, 2018

Copy link
Copy Markdown
Contributor Author

retest this please

1 similar comment
@mageshn

mageshn commented Oct 30, 2018

Copy link
Copy Markdown
Contributor Author

retest this please

@mageshn

mageshn commented Nov 1, 2018

Copy link
Copy Markdown
Contributor Author

@ewencp Let me know if this looks good.

@rayokota rayokota left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some minor nits, otherwise LGTM

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @mageshn! The different locations where the producer and consumer are instantiated has bothered me for some time, so thanks for the taking the initiative to clean this up. I've left a few minor suggestions -- including adding a test or two to verify the assumptions that were in the original code, too.

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated
Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated

@rhauch rhauch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @mageshn! I really like how this helps clean up some of the test cases to no longer need a mock WorkerSinkTask/WorkerSourceTask instances since we can pass in a mock Consumer/Producer.

@mageshn

mageshn commented Nov 5, 2018

Copy link
Copy Markdown
Contributor Author

retest this please

@mageshn

mageshn commented Nov 5, 2018

Copy link
Copy Markdown
Contributor Author

@ewencp/ @hachikuji WDYT about this refactor?

@ewencp ewencp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally looks like a nice refactor and cleanup, just a few comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

connConfig is not used, we should just remove the parameter

Comment thread connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't remember all the details of when the powermock runner ends up being required, but this looks like we may have removed any need for powermock in this test other than Whitebox which may not need it. Would be worth figuring out if we can clean out some powermock usage since it's mostly only used in Connect and has caused problems with newer JDKs.

We don't need to do this here, but if we clean up uses of PowerMock we should consider doing cleanup passes for things like the test runner. Alternatively, might make sense to, at some point, do a JIRA dedicated to just removing use of powermock.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have created a test to address this for Connect. I haven't looked upto see if other components are using it as well. If they do, I will create tickets for those as well. https://issues.apache.org/jira/browse/KAFKA-7686

Comment thread connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine with these as is, but you could also change the methods to be static in Worker and accept the WorkerConfig as a parameter since that's the only class member they use. Would get rid of all the distracting mocks and expect calls and focus the tests on the key functionality of those methods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

indentation issue here, if this is passing checkstyle i would be surprised

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is no longer applicable but AFAIK, this did pass checkstyle.

@mageshn

mageshn commented Nov 29, 2018

Copy link
Copy Markdown
Contributor Author

@ewencp This is ready for another pass. Can you please take another look at it.

@ewencp ewencp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for the clean up!

@ewencp ewencp closed this in ace4dd0 Nov 30, 2018
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
This is minor refactoring that brings in the creation of producer and consumer to the Worker. Currently, the consumer is created in the WorkerSinkTask. This should not affect any functionality and it just makes the code structure easier to understand.

Author: Magesh Nandakumar <magesh.n.kumar@gmail.com>

Reviewers: Ryanne Dolan <ryannedolan@gmail.com>, Randall Hauch <rhauch@gmail.com>, Robert Yokota <rayokota@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes apache#5842 from mageshn/KAFKA-7551
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