psalagnac commented on code in PR #5161:
URL: https://github.com/apache/solr/pull/5161#discussion_r4374968277


##########
solr/core/src/java/org/apache/solr/cloud/ZkDistributedLockFactory.java:
##########
@@ -55,19 +58,57 @@ protected DistributedLock doCreateLock(
     }
   }
 
+  private DistributedLock newLock(boolean isWriteLock, String lockPath, String 
lockIdToMirror)
+      throws KeeperException, InterruptedException {
+    return isWriteLock
+        ? new ZkDistributedLock.Write(zkClient, lockPath, lockIdToMirror)
+        : new ZkDistributedLock.Read(zkClient, lockPath, lockIdToMirror);
+  }
+
   protected StringBuilder getPathPrefix() {
     StringBuilder path = new StringBuilder(100);
     
path.append(rootPath).append(DistributedCollectionConfigSetCommandRunner.ZK_PATH_SEPARATOR);
     return path;
   }
 
-  private void makeLockPath(String lockNodePath) throws KeeperException, 
InterruptedException {
+  private void makeLockPath(String lockPath) throws KeeperException, 
InterruptedException {
+    if (!zkClient.exists(rootPath)) {
+      zkClient.makePath(rootPath, false);
+    }
+    StringBuilder path = new StringBuilder(rootPath);
+    for (String node :
+        lockPath
+            .substring(rootPath.length() + 1)
+            
.split(DistributedCollectionConfigSetCommandRunner.ZK_PATH_SEPARATOR)) {
+      
path.append(DistributedCollectionConfigSetCommandRunner.ZK_PATH_SEPARATOR).append(node);
+      try {
+        zkClient.create(path.toString(), null, CreateMode.CONTAINER);
+      } catch (KeeperException.NodeExistsException nee) {
+        // Some other thread (on this or another JVM) beat us to create the 
node, that's ok.
+      } catch (KeeperException.NoNodeException nne) {
+        // A parent got removed while we were here. The caller retries.
+        return;
+      }
+    }
+  }
+
+  /**
+   * Deletes the empty lock dirs under {@code path}, deepest first. Lock nodes 
and dirs still
+   * holding them are left alone.
+   */
+  protected void deleteEmptyDirs(String path) throws KeeperException, 
InterruptedException {
+    Stat stat = zkClient.exists(path, null);
+    if (stat == null || stat.getEphemeralOwner() != 0) {

Review Comment:
   Thanks



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

Reply via email to