-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-17735. [ARR] LocalResolver#getDatanodesSubcluster adapts to async rpc. #7422
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
HDFS-17735. [ARR] LocalResolver#getDatanodesSubcluster adapts to async rpc. #7422
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@Hexiaoqiao @KeeProMise Sir, cc this pr when you have free time, thanks~ |
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.
Hi, @hfutatzhanghb Regarding this fix LGTM! The current implementation of the getSubclusterInfo method involves an asynchronous call to getDatanodesSubcluster(). Here's the relevant code snippet:
// Fetch the mapping asynchronously
Thread updater = new Thread(new Runnable() {
@Override
public void run() {
final MembershipStore membershipStore = getMembershipStore();
if (membershipStore == null) {
LOG.error("Cannot access the Membership store.");
return;
}
subclusterMapping = getSubclusterInfo(membershipStore);
lastUpdated = monotonicNow();
}
});
updater.start();
// Wait until initialized
if (subclusterMapping == null) {
try {
LOG.debug("Wait to get the mapping for the first time");
updater.join();
} catch (InterruptedException e) {
LOG.error("Cannot wait for the updater to finish");
}
}
When subclusterMapping is null or has not been updated for a long time, an asynchronous thread is started to update subclusterMapping, and the handler thread waits until subclusterMapping is updated.
Instead of starting an asynchronous thread to update subclusterMapping when it is null or stale, and having the handler thread wait for the update to complete, we can modify the approach as follows:
- During router startup, fetch and update subclusterMapping once.
- Start a periodic thread that regularly updates subclusterMapping.
- Handler threads can read from subclusterMapping without waiting for updates, as the periodic thread ensures that subclusterMapping is kept up-to-date.
This approach ensures that the handler threads are not blocked while waiting for subclusterMapping to be updated, improving the overall performance and responsiveness of the system.
@KeeProMise Sir, very nice idea. I think we can implement it in the future. |
88c1ffe
to
4743409
Compare
💔 -1 overall
This message was automatically generated. |
Hi, @Hexiaoqiao @KeeProMise Have added unit test. please help review this PR when you have free time, thanks a lot. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
nnFs1.delete(new Path(testPath), true); | ||
} | ||
assertNotNull(datanodesSubcluster); | ||
assertTrue(!datanodesSubcluster.isEmpty()); |
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.
Hi @hfutatzhanghb assertFalse(datanodesSubcluster.isEmpty()) may better. others LGTM!
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.
@KeeProMise Thanks a lot for your reviewing, have fixed. Wait yetus~
🎊 +1 overall
This message was automatically generated. |
LGTM! will merge tonight if no more comments. |
hi @hfutatzhanghb thanks for your contribution! merged. |
@KeeProMise Thanks a lot for reviewing and merging ! |
…c rpc. (apache#7422). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <[email protected]>
Description of PR
LocalResolver#getDatanodesSubcluster adapts to async rpc.