You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/11/13 02:06:21 UTC

[GitHub] [hadoop] goiri commented on a diff in pull request #5111: YARN-11350. [Federation] Router Support DelegationToken With ZK.

goiri commented on code in PR #5111:
URL: https://github.com/apache/hadoop/pull/5111#discussion_r1020829032


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java:
##########
@@ -1002,7 +1053,9 @@ public RouterRMTokenResponse removeStoredToken(RouterRMTokenRequest request)
   @Override
   public RouterRMTokenResponse getTokenByRouterStoreToken(RouterRMTokenRequest request)
       throws YarnException, IOException {
+    request.getRouterStoreToken().getTokenIdentifier();
     throw new NotImplementedException("Code is not implemented");

Review Comment:
   Didn't we implement it?



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java:
##########
@@ -129,6 +135,7 @@
  * |--- RESERVATION
  * |     |----- RESERVATION1
  * |     |----- RESERVATION2
+ * |---

Review Comment:
   I don't think we need this?



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java:
##########
@@ -1012,45 +1065,80 @@ private static DelegationKey getDelegationKeyByMasterKey(RouterMasterKey masterK
     return new DelegationKey(masterKey.getKeyId(), masterKey.getExpiryDate(), keyBytes);
   }
 
-  private String getLeafDelegationTokenNodePath(int rmDTSequenceNumber,
-      boolean createParentIfNotExists) throws Exception {
-    return getLeafDelegationTokenNodePath(rmDTSequenceNumber,
-        createParentIfNotExists, delegationTokenNodeSplitIndex);
+  @VisibleForTesting
+  boolean exists(final String path) throws Exception {
+    return zkManager.exists(path);
   }
 
-  private String getLeafDelegationTokenNodePath(int rmDTSequenceNumber,
-      boolean createParentIfNotExists, int split) throws Exception {
-    String nodeName = DELEGATION_TOKEN_PREFIX;
-    if (split == 0) {
-      nodeName += rmDTSequenceNumber;
+  /**
+   * Add or update delegationToken.
+   *
+   * @param routerStoreToken storeToken
+   * @param isUpdate true, update the token; false, create a new token.
+   *
+   * @throws Exception exception occurs.
+   */
+  protected void storeOrUpdateRouterRMDT(RouterStoreToken routerStoreToken, boolean isUpdate)
+      throws Exception {
+    YARNDelegationTokenIdentifier tokenIdentifier = routerStoreToken.getTokenIdentifier();
+    int sequenceNumber = tokenIdentifier.getSequenceNumber();
+
+    String nodeCreatePath =
+        getNodePath(RM_DELEGATION_TOKENS_ROOT_ZNODE_NAME,
+        DELEGATION_TOKEN_PREFIX + sequenceNumber);
+
+    LOG.debug("nodeCreatePath = {}, isUpdate = {}", nodeCreatePath, isUpdate);
+
+    if (isUpdate) {
+      put(nodeCreatePath, routerStoreToken.toByteArray(), true);
     } else {
-      nodeName += String.format("%04d", rmDTSequenceNumber);
+      put(nodeCreatePath, routerStoreToken.toByteArray(), false);

Review Comment:
   put(nodeCreatePath, routerStoreToken.toByteArray(), isUpdate);



-- 
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.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org