-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-12177] Refactored some API in Kafka 0.10 to make public API simpler #13996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test build #61540 has finished for PR 13996 at commit
|
| import org.apache.spark.annotation.Experimental; | ||
|
|
||
| /** | ||
| * :: Experimental :: Choice of how to create and configure underlying Kafka Consumers on driver and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix docs
|
Test build #61541 has finished for PR 13996 at commit
|
|
I've got concerns about this, please don't merge these refactorings until I
|
|
Test build #61543 has finished for PR 13996 at commit
|
|
I'll leave line comments about specific things, but my major overarching concern is about moving the interface to a Java abstract class. As far as I can tell, nothing being done in that class couldn't be done in Scala. If this is just a reaction to not wanting autogenerated apply methods, nothing's stopping us from making a standalone non-companion object with the exact same interface you're proposing. More important in my opinion is the reasoning behind moving to an abstract class. Nothing about the definition of that interface requires constructor state, so a class doesn't make sense. If your thinking here is that you want to be able to later add methods with a default implementation without relying on Java 8 features... I'm really opposed to this line of reasoning. This is prioritizing binary compatibility at the cost of silently breaking people's code when APIs really do need to change. If the interface needs to change, and a bunch of people have already implemented that interface in their own code, which would you rather have as a user? Know at compile time that this interface, (which is marked as experimental) needs to change, figure out how it changed, and write the right thing for your use case? Or silently have it "work"... until you find out at runtime (or in a business meeting about why metrics are now wrong) that the default implementation the spark project added does totally the wrong thing for your use case? |
| * NOT zookeeper servers, specified in host1:port1,host2:port2 form. | ||
| * @param consumerStrategy In most cases, pass in [[Subscribe]], | ||
| * see [[ConsumerStrategy]] for more details | ||
| * @param consumerStrategy In most cases, pass in [[SubscribeStrategy]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't hide PreferConsistent and SusbscribeStrategy from users and then tell them to pass it in...
|
So another concrete reason I'm against moving the strategy interfaces to java is that LocationStrategy is no longer sealed, so we lose exhaustivity checking on the cases. LocationStrategy is a tagged union / sum type / whatever you want to call it. It's definitely not an OO hierarchy, and users shouldn't be extending it. |
|
See the linked pr #13998 for an example of what I'm proposing. I'll make sure the same thing works for consumer strategy and update that pr. If you let me know where you were actually running into serialization issues I can address those too - see note above. |
| } | ||
|
|
||
|
|
||
| public static LocationStrategy PreferFixed(Map<TopicPartition, String> hostMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: docs?
|
Let me note down all the concerns clearly.
The resultant public interfaces are as expected. So this should be fine if written in Scala.
Your PR #13998 is going in the right direction. I am stuck for the next couple of hours in meetings. So if you dont mind could you update your PR? In addition, for testing, I noticed that the JavaConsumerStrategySuite used |
|
"When abstract class, you can later add defined methods which the users can override if needed, but does not break compatibility of existing implementations." This is what I'm taking issue with. It's confusing binary compatibility with actual api compatibility. Changing the class and silently slipping in a new default method into someone's code may preserve binary compatibility, at the cost of actually breaking their code at runtime and losing them their job. Clearly not a big change from a lines of code perspective to move trait to abstract class, so I can do it quickly, but I'd like to at least hear your response to that concern. Other changes, no concerns, I can add them to my pr |
|
I am closing this PR. This PR is superseded by #13998 |
## What changes were proposed in this pull request? This is an alternative to the refactoring proposed by #13996 ## How was this patch tested? unit tests also tested under scala 2.10 via mvn -Dscala-2.10 Author: cody koeninger <[email protected]> Closes #13998 from koeninger/kafka-0-10-refactor.
## What changes were proposed in this pull request? This is an alternative to the refactoring proposed by #13996 ## How was this patch tested? unit tests also tested under scala 2.10 via mvn -Dscala-2.10 Author: cody koeninger <[email protected]> Closes #13998 from koeninger/kafka-0-10-refactor. (cherry picked from commit fbfd0ab) Signed-off-by: Tathagata Das <[email protected]>
What changes were proposed in this pull request?
This refactoring make the public API simpler. Current version has the following problems
applyandcreatemethods for Scala and Java.To fix these, I have refactored the classes. Now
LocationStrategyhas static methods to create the appropriate strategy. E.g.Similarly,
1+2. This allows all the strategy classes to be hidden from public, less surface for incompatibility in the future. And same APIs for Java and Scala.
3. In addition, both strategies have been implemented as abstract class in Java.
How was this patch tested?
Modified unit tests.
TODO: More unit tests to