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-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org