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


##########
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:
   Move the if into:
   ```
   } else if (appIdNodeSplitIndex != 0) {
   ```



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

Reply via email to