slfan1989 commented on code in PR #6016:
URL: https://github.com/apache/hadoop/pull/6016#discussion_r1331838567
##########
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:
##########
@@ -761,11 +867,46 @@ private ApplicationHomeSubCluster
getApplicationHomeSubCluster(
private void storeOrUpdateApplicationHomeSubCluster(final ApplicationId
applicationId,
final ApplicationHomeSubCluster applicationHomeSubCluster, boolean
update)
throws YarnException {
- String appZNode = getNodePath(appsZNode, applicationId.toString());
- ApplicationHomeSubClusterProto proto =
- ((ApplicationHomeSubClusterPBImpl)
applicationHomeSubCluster).getProto();
- byte[] data = proto.toByteArray();
- put(appZNode, data, update);
+ try {
+ ApplicationHomeSubClusterProto proto =
+ ((ApplicationHomeSubClusterPBImpl)
applicationHomeSubCluster).getProto();
+ byte[] data = proto.toByteArray();
+ if (update) {
+ updateApplicationStateInternal(applicationId, data);
+ } else {
+ storeApplicationStateInternal(applicationId, data);
+ }
+ } catch (Exception e) {
+ throw new YarnException(e);
+ }
+ }
+
+ protected void storeApplicationStateInternal(final ApplicationId
applicationId, byte[] data)
+ throws Exception {
+ String nodeCreatePath = getLeafAppIdNodePath(applicationId.toString(),
true);
+ LOG.debug("Storing info for app: {} at: {}.", applicationId,
nodeCreatePath);
+ put(nodeCreatePath, data, false);
+ }
+
+ protected void updateApplicationStateInternal(final ApplicationId
applicationId, byte[] data)
+ throws Exception {
+ String nodeUpdatePath = getLeafAppIdNodePath(applicationId.toString(),
false);
+ if (!exists(nodeUpdatePath)) {
+ AppNodeSplitInfo alternatePathInfo =
getAlternatePath(applicationId.toString());
+ if (alternatePathInfo != null) {
+ nodeUpdatePath = alternatePathInfo.path;
+ } else {
+ // No alternate path exists. Create path as per configured split index.
+ if (appIdNodeSplitIndex != 0) {
Review Comment:
Thanks for your suggestion! 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]