slfan1989 commented on code in PR #5111:
URL: https://github.com/apache/hadoop/pull/5111#discussion_r1020897813
##########
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:
I will fix it.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]