-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
HDFS-17596. [ARR] RouterStoragePolicy supports asynchronous rpc. #6988
Conversation
|
||
import static org.apache.hadoop.hdfs.server.federation.router.async.AsyncUtil.asyncReturn; | ||
|
||
public class AsyncRouterStoragePolicy extends RouterStoragePolicy { |
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.
@hfutatzhanghb Hi, thanks for your contribution. Should we change the name of this class to RouterAsyncStoragePolicy?
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 Sir, thanks for reviewing. OK, i will fix it and we keep the same style for other Class name.
public BlockStoragePolicy getStoragePolicy(String path) | ||
throws IOException { | ||
rpcServer.checkOperation(NameNode.OperationCategory.READ, true); | ||
|
||
List<RemoteLocation> locations = | ||
rpcServer.getLocationsForPath(path, false, false); | ||
RemoteMethod method = new RemoteMethod("getStoragePolicy", | ||
new Class<?>[] {String.class}, | ||
new RemoteParam()); |
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 method does not seem to require asynchronous transformation, just use the parent class.
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.
have done
4e0b405
to
a591902
Compare
Hi, @hfutatzhanghb HDFS-17545 has already been merged into HDFS-17531, please rebase your development branch using HDFS-17531. |
8169421
to
2af8558
Compare
💔 -1 overall
This message was automatically generated. |
.../src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAsyncStoragePolicy.java
Show resolved
Hide resolved
...-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
Outdated
Show resolved
Hide resolved
// If no namespace is available, throw IOException. | ||
IOException io = new IOException("No namespace available."); | ||
|
||
asyncComplete(null); |
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 IMO, asyncComplete(null) is not needed in this place.
}); | ||
}); | ||
|
||
asyncCatch((AsyncCatchFunction<T, IOException>)(ret, ex) -> { |
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.
Should use CatchFunction.
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
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 I found that the reason why the UT failed was that RouterRpcServer used RouterRpcClient instead of RouterAsyncRpcClient when calling the invokeOnNsAsync and invokeAtAvailableNsAsync methods in the UT, resulting in null.
I gave a fix suggestion, maybe you have a better approach.
// If default Ns is present return result from that namespace. | ||
if (!nsId.isEmpty()) { | ||
asyncTry(() -> { | ||
rpcClient.invokeSingle(nsId, method, clazz); |
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 this can fix UT
getRPCClient().invokeSingle(nsId, method, clazz);
String nsId = fnInfo.getNameserviceId(); | ||
LOG.debug("Invoking {} on namespace {}", method, nsId); | ||
asyncTry(() -> { | ||
rpcClient.invokeSingle(nsId, method, clazz); |
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.
Same as above.
getRPCClient().invokeSingle(nsId, method, clazz);
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 Sir, Thanks for your reviewing and pointing out the problem, i will fix it soonly.
...-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
Outdated
Show resolved
Hide resolved
...-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
Outdated
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
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 LGTM! @Hexiaoqiao if you have time, please help to review the pr.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -791,6 +800,36 @@ <T> T invokeAtAvailableNs(RemoteMethod method, Class<T> clazz) | |||
return invokeOnNs(method, clazz, io, nss); | |||
} | |||
|
|||
<T> T invokeAtAvailableNsAsync(RemoteMethod method, Class<T> clazz) |
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.
How about to split this changes to separate PR which is common update and not relate with StoragePolicy only. Others look good to me. 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.
@Hexiaoqiao @KeeProMise Agree with you, sir. This PR depends on #7108
, I have splited this chanages to PR #7108. PTAL. thanks a lot.
Hi @hfutatzhanghb , what's relationship between this PR and #7108 , any dependency? Thanks. |
@Hexiaoqiao Sir, thanks for reviewing. #7108 implements methods invokeAtAvailableNsAsync which is needed by this PR. |
LGTM. Let's wait #7108 check in first, then push this one forward. Thanks. |
Hi @hfutatzhanghb @KeeProMise Consider that #7108 (which is approved now) is pending to check in. I think this one is ready to check in too after merge #7108 . BTW, we need rebase trunk again. Thanks. |
@Hexiaoqiao Thanks sir and Thanks @KeeProMise for push UT for #7108 . |
# Conflicts: # hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
🎊 +1 overall
This message was automatically generated. |
@hfutatzhanghb @Hexiaoqiao Hi, I will merge this pr later, if no comment here. |
@hfutatzhanghb thanks for your contribution, and @Hexiaoqiao thanks for your review! merged |
hi, @Hexiaoqiao if you have time, please help to rebase trunk again, thanks! |
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
…ache#6988). Contributed by hfutatzhanghb. Reviewed-by: Jian Zhang <keepromise@apache.org> Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
Description of PR
The main new addition is RouterAsyncStoragePolicy, which extends RouterStoragePolicy so that supports asynchronous rpc.