From 139d850e850277cfc0fd5e0da15abe1467b8fa5c Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Thu, 16 Jan 2025 19:01:29 -0500 Subject: [PATCH] Remove zookeeper-jute from minicluster (#5261) Use ZooReaderWriter to do ZK updates in MiniAccumuloClusterImpl instead of requiring zookeeper-jute on the classpath (also makes the code shorter and more readable) --- minicluster/pom.xml | 4 ---- .../miniclusterImpl/MiniAccumuloClusterImpl.java | 14 ++++---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/minicluster/pom.xml b/minicluster/pom.xml index 50ca43cdc71..9904356bfff 100644 --- a/minicluster/pom.xml +++ b/minicluster/pom.xml @@ -96,10 +96,6 @@ org.apache.zookeeper zookeeper - - org.apache.zookeeper - zookeeper-jute - org.slf4j slf4j-api diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java index 86cec11696d..4eddb61c9e2 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java @@ -81,7 +81,7 @@ import org.apache.accumulo.core.data.InstanceId; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; -import org.apache.accumulo.core.fate.zookeeper.ZooUtil; +import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.core.lock.ServiceLock; import org.apache.accumulo.core.lock.ServiceLock.AccumuloLockWatcher; import org.apache.accumulo.core.lock.ServiceLock.LockLossReason; @@ -121,7 +121,6 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -723,14 +722,9 @@ public void failedToAcquireLock(Exception e) { String miniZDirPath = miniZInstancePath.substring(0, miniZInstancePath.indexOf("/" + miniUUID.toString())); try { - if (miniLockZk.exists(miniZDirPath, null) == null) { - miniLockZk.create(miniZDirPath, new byte[0], ZooUtil.PUBLIC, CreateMode.PERSISTENT); - log.info("Created: {}", miniZDirPath); - } - if (miniLockZk.exists(miniZInstancePath, null) == null) { - miniLockZk.create(miniZInstancePath, new byte[0], ZooUtil.PUBLIC, CreateMode.PERSISTENT); - log.info("Created: {}", miniZInstancePath); - } + var zrw = miniLockZk.asReaderWriter(); + zrw.putPersistentData(miniZDirPath, new byte[0], NodeExistsPolicy.SKIP); + zrw.putPersistentData(miniZInstancePath, new byte[0], NodeExistsPolicy.SKIP); } catch (KeeperException | InterruptedException e) { throw new IllegalStateException("Error creating path in ZooKeeper", e); }