-
Notifications
You must be signed in to change notification settings - Fork 9k
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
base: trunk
Are you sure you want to change the base?
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. |
Description of PR
LocalResolver#getDatanodesSubcluster adapts to async rpc.