srdo commented on a change in pull request #361: HBase-22027: Split non-MR 
related parts of TokenUtil off into a Clien…
URL: https://github.com/apache/hbase/pull/361#discussion_r300840219
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/TokenUtil.java
 ##########
 @@ -57,142 +45,70 @@
   // This class is referenced indirectly by User out in common; instances are 
created by reflection
   private static final Logger LOG = LoggerFactory.getLogger(TokenUtil.class);
 
-  // Set in TestTokenUtil via reflection
-  private static ServiceException injectedException;
-
-  private static void injectFault() throws ServiceException {
-    if (injectedException != null) {
-      throw injectedException;
-    }
-  }
-
   /**
-   * Obtain and return an authentication token for the current user.
-   * @param conn The async HBase cluster connection
-   * @return the authentication token instance, wrapped by a {@link 
CompletableFuture}.
+   * See {@link 
ClientTokenUtil#obtainToken(org.apache.hadoop.hbase.client.AsyncConnection)}.
+   * @deprecated Please use the corresponding method in {@link 
ClientTokenUtil} instead.
    */
+  @Deprecated
   public static CompletableFuture<Token<AuthenticationTokenIdentifier>> 
obtainToken(
       AsyncConnection conn) {
-    CompletableFuture<Token<AuthenticationTokenIdentifier>> future = new 
CompletableFuture<>();
-    if (injectedException != null) {
-      future.completeExceptionally(injectedException);
-      return future;
-    }
-    AsyncTable<?> table = conn.getTable(TableName.META_TABLE_NAME);
-    table.<AuthenticationService.Interface, GetAuthenticationTokenResponse> 
coprocessorService(
-      AuthenticationProtos.AuthenticationService::newStub,
-      (s, c, r) -> s.getAuthenticationToken(c,
-        
AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance(), r),
-      HConstants.EMPTY_START_ROW).whenComplete((resp, error) -> {
-        if (error != null) {
-          
future.completeExceptionally(ProtobufUtil.handleRemoteException(error));
-        } else {
-          future.complete(toToken(resp.getToken()));
-        }
-      });
-    return future;
+    return ClientTokenUtil.obtainToken(conn);
   }
 
   /**
-   * Obtain and return an authentication token for the current user.
-   * @param conn The HBase cluster connection
-   * @throws IOException if a remote error or serialization problem occurs.
-   * @return the authentication token instance
+   * See {@link 
ClientTokenUtil#obtainToken(org.apache.hadoop.hbase.client.Connection)}.
+   * @deprecated Please use the corresponding method in {@link 
ClientTokenUtil} instead.
 
 Review comment:
   I'm going by the posts here 
https://issues.apache.org/jira/browse/HBASE-22027?focusedCommentId=16789499&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16789499.
 As I understand, these methods should be IA.Private, as they return types that 
are IA.Private.
   
   I don't know if there's a public replacement, but I'm happy to update the 
deprecation notice.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to