abstractdog commented on code in PR #4901:
URL: https://github.com/apache/hive/pull/4901#discussion_r1411893743


##########
llap-client/src/java/org/apache/hadoop/hive/registry/impl/ZkRegistryBase.java:
##########
@@ -353,6 +356,26 @@ protected final void updateServiceRecord(
     }
   }
 
+  protected void ensurePersistentNodePath(ServiceRecord srv) throws 
IOException {
+    try {
+      String pNodePath = "/" + PATH_JOINER.join(namespace, 
StringUtils.substringBetween(workersPath, "/", "/"),
+          "pnode0");
+      LOG.info("Check if persistent node  path {}  exists, create if not", 
pNodePath);
+      if (zooKeeperClient.checkExists().forPath(pNodePath) == null) {
+        
zooKeeperClient.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT)
+            .forPath(pNodePath, encoder.toBytes(srv));
+        LOG.info("Created persistent path at: {}", pNodePath);
+      }
+    } catch (Exception e) {
+      // throw exception if it is other than NODEEXISTS.
+      if (!(e instanceof KeeperException) || ((KeeperException) e).code() != 
KeeperException.Code.NODEEXISTS) {
+        LOG.error("Unable to create a persistent znode for this server 
instance", e);
+        throw new IOException(e);
+      }else{

Review Comment:
   nit:
   ```
   }else{
   ```
   should be:
   ```
   } else {
   ```
   mind the spaces, btw you can auto-format according to this style definition:
   https://github.com/apache/hive/blob/master/dev-support/eclipse-styles.xml
   
   another nit:
   ```
   LOG.info( "Ignore as the parent node already exists.");
   ```
   will result an INFO level message without any context: Ignore "something" as 
the parent node of "something" already exists, I would switch to this message 
(and I realized DEBUG is fine as else branch is called under normal 
circumstances)
   ```
   LOG.debug( "Ignoring KeeperException while ensuring path as the parent node 
{} already exists.", parentNode);
   ```
   



-- 
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: gitbox-unsubscr...@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to