-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-4011] tighten the visibility of the members in Master/Worker class #4844
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
|
Hi, @srowen, would you mind taking the review? Also, though the current fix is only for Master/Worker class, I found that "too much visibility" problem is prevalent in the deploy package do we want to fix it in a shot? |
|
Test build #28147 has started for PR 4844 at commit
|
|
Test build #28147 has finished for PR 4844 at commit
|
|
Test FAILed. |
|
Test build #28148 has started for PR 4844 at commit
|
|
Test build #28148 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
This follows discussion at #2828 (comment) I also agree that these many fields and members can be private, and do not seem to have been intended to be non-private. (They can be made so later; this is not a public API.) So I support this and clearly it compiles and passes tests. I might like a yea/nay from @JoshRosen or @markhamstra who were part of the original discussion though. |
|
I'm in favor of this change. Even if this class is private within the deploy package, keeping everything at the minimum visibility is a good programming practice and makes the code easier to reason about. |
|
Thanks, @srowen and @JoshRosen , So, shall we propogate this change to other classes in the deploy package, in this PR or a different PR? e.g. https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/deploy/master/DriverInfo.scala#L33 can be changed to private[deploy] |
|
I imagine there are lots of fields that could and even should be |
|
sure, thanks @srowen , I will try to address it today |
|
Test build #28181 has started for PR 4844 at commit
|
|
Test build #28186 has started for PR 4844 at commit
|
|
Test build #28181 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
Test build #28186 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
Hi, @srowen and @JoshRosen I made further changes. Basically, I got 2 kinds of strategies to tighten the accessibility
One more thing to mention is that I didn't apply the most restrict permission to all places, because I guess in some of the places, the original authors intentionally made more loose accessibility for easier extension in future, e.g. in https://github.com/apache/spark/pull/4844/files#diff-829a8674171f92acd61007bedb1bfa4fR40 (DriverRunner), some of the public variables declared in the constructor is not necessary (e.g. workerUrl), but some of the public variables declared together is read in other classes (e.g. driverId is read in WorkerPage), in such cases, I didn't limit workerUrl as private, since in future we might add more rich content to WorkerPage.... |
|
Oh my, I didn't realize this would expand to change 50 files. In many cases you're removing visibility restrictions. I understand that the class-level visibility still constrains it but it's part of why the change is large now. I don't feel qualified to judge whether this is too much change or not. It seems like the original much smaller commit was certainly a good change, at the least. I agree that it does feel right to lock down visibility to improve reasoning about the code. |
|
yeah, in many cases, the class is exposed as I scan the code base, found that this is not an intentional design , as in some classes like https://github.com/CodingCat/spark/blob/SPARK-4011/core/src/main/scala/org/apache/spark/deploy/history/HistoryServerArguments.scala#L26 the class is restricted in its local package, which I thought to be the right choice so I followed this idea and made the changes |
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.
I think this might be going a little too far. It's probably OK for all of these to just be private[deploy]
|
@CodingCat I'm in full support for the changes that involve changing |
|
Test build #28247 has started for PR 4844 at commit
|
|
Hi, @andrewor14 , thank you very much for the comments
But I still keep some of them, which mainly stay in The reason is that 1) for SparkSubmit, those methods are just accessed by the object itself as well as the unit test suite...I guess leaving them to be accessible across the whole code base is not that "elegant"? 2) for ApplicationInfo...it's more than "elegance", I think we may not wish the classes from outside of master package can change the internal status of ApplicationInfo instance?
|
|
Test build #28247 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
@srowen @andrewor14 @JoshRosen do you have further comments about the patch? |
|
Test build #28526 has started for PR 4844 at commit
|
|
Test build #28526 has finished for PR 4844 at commit
|
|
Test FAILed. |
|
Test build #28533 has started for PR 4844 at commit
|
|
Test build #28533 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
I like this. It is tightening visibility only on Spark-private classes, so there should be no API impact. MiMa doesn't report problems, except:
|
|
Test build #28536 has started for PR 4844 at commit
|
|
Test build #28536 has finished for PR 4844 at commit
|
|
Test FAILed. |
|
Test build #28537 has started for PR 4844 at commit
|
|
Test build #28537 has finished for PR 4844 at commit
|
|
Test PASSed. |
|
@srowen you're right, I addressed the comments |
|
Let me let @andrewor14 have a couple more days to weigh in, but this looks good to me. I believe he's broadly in favor of the change, and you have backed out any changes that potentially make something public into non-public, and removed some of the per-method changes too. MiMa is happy. |
|
sure, thanks |
|
Going once, going twice for more comments on this change. It touches a number of files but is a good tightening of visibility. |
|
thanks @srowen |
https://issues.apache.org/jira/browse/SPARK-4011
Currently, most of the members in Master/Worker are with public accessibility. We might wish to tighten the accessibility of them
a bit more discussion is here:
#2828