- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9.1k
HDFS-17793. [ARR] RBF: Enable the router asynchronous RPC feature to handle DelegationToken request errors #7714
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
… getDelegationToken request errors
| Hi, @zhangxiping1 . Thanks for reporting this problem. Make sense to me. | 
| 
   @Override
  public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
      throws IOException {
    rpcServer.checkOperation(NameNode.OperationCategory.WRITE, true);
    asyncComplete(this.securityManager.getDelegationToken(renewer));
    return asyncReturn(Token.class);
  }
  @Override
  public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
      throws IOException {
    rpcServer.checkOperation(NameNode.OperationCategory.WRITE, true);
    asyncComplete(this.securityManager.renewDelegationToken(token));
    return asyncReturn(Long.class);
  }
  @Override
  public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)
      throws IOException {
    rpcServer.checkOperation(NameNode.OperationCategory.WRITE, true);
    this.securityManager.cancelDelegationToken(token);
    asyncComplete(null);
  } | 
| 
 @KeeProMise ok,I'll revise and submit the following later. | 
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.
Pull Request Overview
Enable the router’s asynchronous RPC support for delegation token operations by removing the old synchronous overrides and adding a basic test.
- Added a test stub for getDelegationTokenin the async RPC test suite.
- Removed the synchronous getDelegationToken,renewDelegationToken, andcancelDelegationTokenoverrides in favor of the async router mechanism.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description | 
|---|---|
| hadoop-hdfs-project/.../TestRouterAsyncRpc.java | Added testgetDelegationTokenstub without assertions | 
| hadoop-hdfs-project/.../RouterClientNamenodeProtocolServerSideTranslatorPB.java | Removed synchronous delegation-token RPC overrides | 
Comments suppressed due to low confidence (2)
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java:95
- [nitpick] The method name testgetDelegationTokenis inconsistent with camelCase conventions; consider renaming it totestGetDelegationTokenfor readability and consistency.
public void testgetDelegationToken() throws Exception {
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterClientNamenodeProtocolServerSideTranslatorPB.java:979
- The synchronous overrides for delegation token operations were removed without replacement; callers of these RPCs will now receive null. Implement the asyncRouterServer logic forgetDelegationToken,renewDelegationToken, andcancelDelegationTokento ensure proper handling.
@Override
|  | ||
| @Test | ||
| public void testgetDelegationToken() throws Exception { | ||
| rndRouter.getFileSystem().getDelegationToken("yarn"); | 
    
      
    
      Copilot
AI
    
    
    
      May 27, 2025 
    
  
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 test does not include any assertions to verify the returned token or expected error; add assertions (e.g., assertNotNull or expected exception) to validate behavior.
| rndRouter.getFileSystem().getDelegationToken("yarn"); | |
| // Get the delegation token for the user "yarn". | |
| org.apache.hadoop.security.token.Token<?> token = | |
| rndRouter.getFileSystem().getDelegationToken("yarn"); | |
| // Assert that the token is not null. | |
| assertNotNull(token, "Delegation token should not be null"); | |
| // Optionally, verify additional properties of the token. | |
| assertEquals("yarn", token.getService().toString(), | |
| "The token service should match the requested user"); | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
…handle DelegationToken request errors
… to handle DelegationToken request errors
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| @zhangxiping1 Here is a Checkstyle exception /hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java:171: protected RouterSecurityManager securityManager = null;:35: Variable 'securityManager' must be private and have accessor methods. [VisibilityModifier] | 
| 
 ok ,I'll make some more revisions. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| 💔 -1 overall 
 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| @KeeProMise hi, lao tie, it seems to be okay. | 
| 
 @zhangxiping1 LGTM + 1. Let's wait for two days to see if there are any other comments. | 
|  | ||
|  | 
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 @zhangxiping1 Just leave a blank line here.
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.
ok
| 🎊 +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.
Pull Request Overview
This PR enables the router’s asynchronous RPC feature to support delegation token operations and adds a basic test for the new async getDelegationToken call.
- Added async implementations for getDelegationToken,renewDelegationToken, andcancelDelegationTokeninRouterAsyncClientProtocol
- Exposed getSecurityManager()inRouterClientProtocolto back the async handlers
- Introduced a new test to verify no exception is thrown when calling getDelegationTokenasynchronously
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description | 
|---|---|
| TestRouterAsyncRpc.java | Added testGetDelegationTokenAsyncRpcusingassertDoesNotThrow | 
| RouterAsyncClientProtocol.java | Implemented async methods for delegation token operations | 
| RouterClientProtocol.java | Exposed getSecurityManager()getter | 
Comments suppressed due to low confidence (2)
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java:97
- The test only asserts that no exception is thrown; consider adding assertNotNullon the returned token to validate the async call actually returns a valid delegation token.
assertDoesNotThrow(() -> {
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java:94
- There are no tests covering renewDelegationTokenorcancelDelegationTokenasync methods; consider adding similar tests to ensure those flows handle errors correctly.
@Test
| throws IOException { | ||
| rpcServer.checkOperation(NameNode.OperationCategory.WRITE, true); | ||
| asyncComplete(getSecurityManager().getDelegationToken(renewer)); | ||
| return asyncReturn(Token.class); | 
    
      
    
      Copilot
AI
    
    
    
      May 28, 2025 
    
  
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.
[nitpick] Using asyncReturn(Token.class) loses the generic type information (DelegationTokenIdentifier). Consider an explicit cast or adding @SuppressWarnings("unchecked") to make the conversion clear and safe.
| return asyncReturn(Token.class); | |
| return (Token<DelegationTokenIdentifier>) asyncReturn(Token.class); | 
| return rbfRename; | ||
| } | ||
|  | ||
| public RouterSecurityManager getSecurityManager() { | 
    
      
    
      Copilot
AI
    
    
    
      May 28, 2025 
    
  
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 new public getter lacks Javadoc and audience annotations; consider adding a brief description and an @InterfaceAudience tag to clarify intended use.
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.
LGTM. +1
| Hi @zhangxiping1 thanks for your contribution! @hfutatzhanghb thanks for your review. merged! | 
…handle DelegationToken request errors. (apache#7714). Contributed by zhangxiping1. Reviewed-by: Jian Zhang <[email protected]>

Enable the router asynchronous RPC feature to handle getDelegationToken request errors.