-
Notifications
You must be signed in to change notification settings - Fork 275
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
Cleanup ReplicationEngine:createThreadPool to avoid hardcoding Vcr #1781
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1781 +/- ##
=============================================
- Coverage 73.82% 62.01% -11.82%
+ Complexity 9348 7792 -1556
=============================================
Files 682 688 +6
Lines 51435 52142 +707
Branches 6400 6480 +80
=============================================
- Hits 37973 32335 -5638
- Misses 11466 17744 +6278
- Partials 1996 2063 +67 Continue to review full report at Codecov.
|
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.
Thanks for contributing. See inline comment.
* @param threadIndexWithinPool The index of the thread within the thread pool. | ||
* @return The name of the thread. | ||
*/ | ||
protected String getReplicaThreadName(String datacenterToReplicateFrom, int threadIndexWithinPool) { |
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.
If the only difference is the prefix, the method could be getReplicaThreadPrefix() with no arguments.
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.
Yep, agreed. Though I named it like this on purpose to
- prevent the creation of very specialized functions
- allow the subclass needs to add more details to the thread name if needed
What do you think? I'm also okay with changing it to your suggestion.
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.
This is a good change. Thanks @parasgithub for making this change. I don't disagree with your argument to allow the subclasses to add more details to the thread name if needed.
However, I have a nitpick in that case. I think other than prefix, the rest of the logic is repeated code. Can you separate them out, so that it is ensured that thread naming convention doesn't change inadvertently in subclasses, unless explicitly desired.
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.
Done, please take a look
6a311c6
to
2739d6a
Compare
* @param threadIndexWithinPool The index of the thread within the thread pool. | ||
* @return The name of the thread. | ||
*/ | ||
public static String getCanonicalReplicaThreadName(String datacenterToReplicateTo, String datacenterToReplicateFrom, int threadIndexWithinPool) { |
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 see what you're doing here, but I don't think this method really belongs here. ThreadIndexWithinPool is a concept that only the ReplicationManager knows about, so I would move it there.
@@ -271,6 +267,11 @@ public long getRemoteReplicaLagFromLocalInBytes(PartitionId partitionId, String | |||
return -1; | |||
} | |||
|
|||
@Override | |||
protected String getReplicaThreadName(String datacenterToReplicateFrom, int threadIndexWithinPool) { | |||
return "Vcr" + ReplicaThread.getCanonicalReplicaThreadName(dataNodeId.getDatacenterName(), datacenterToReplicateFrom, threadIndexWithinPool); |
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.
This can be simply:
return "Vcr" + super. getReplicaThreadName(datacenterToReplicateFrom, threadIndexWithinPool);
And then I think the canonical logic can be collapsed back into the superclass method.
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.
Sorry about the delay. Made the change.
f7458d7
to
44069a7
Compare
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.
Looks good. Will merge once the build passes.
@parasgithub Do you want to take a stab at fixing the failing test? |
44069a7
to
cb4ea1e
Compare
Done |
Sending a short pull request to make sure change is OK, will add a test afterwards (in same branch) if needed.
Issue #1742