Skip to content

Commit 139d850

Browse files
authored
Remove zookeeper-jute from minicluster (apache#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)
1 parent 2a12b13 commit 139d850

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

minicluster/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
<groupId>org.apache.zookeeper</groupId>
9797
<artifactId>zookeeper</artifactId>
9898
</dependency>
99-
<dependency>
100-
<groupId>org.apache.zookeeper</groupId>
101-
<artifactId>zookeeper-jute</artifactId>
102-
</dependency>
10399
<dependency>
104100
<groupId>org.slf4j</groupId>
105101
<artifactId>slf4j-api</artifactId>

minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
import org.apache.accumulo.core.data.InstanceId;
8282
import org.apache.accumulo.core.data.TableId;
8383
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
84-
import org.apache.accumulo.core.fate.zookeeper.ZooUtil;
84+
import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy;
8585
import org.apache.accumulo.core.lock.ServiceLock;
8686
import org.apache.accumulo.core.lock.ServiceLock.AccumuloLockWatcher;
8787
import org.apache.accumulo.core.lock.ServiceLock.LockLossReason;
@@ -121,7 +121,6 @@
121121
import org.apache.hadoop.fs.Path;
122122
import org.apache.hadoop.hdfs.DFSConfigKeys;
123123
import org.apache.hadoop.hdfs.MiniDFSCluster;
124-
import org.apache.zookeeper.CreateMode;
125124
import org.apache.zookeeper.KeeperException;
126125
import org.slf4j.Logger;
127126
import org.slf4j.LoggerFactory;
@@ -723,14 +722,9 @@ public void failedToAcquireLock(Exception e) {
723722
String miniZDirPath =
724723
miniZInstancePath.substring(0, miniZInstancePath.indexOf("/" + miniUUID.toString()));
725724
try {
726-
if (miniLockZk.exists(miniZDirPath, null) == null) {
727-
miniLockZk.create(miniZDirPath, new byte[0], ZooUtil.PUBLIC, CreateMode.PERSISTENT);
728-
log.info("Created: {}", miniZDirPath);
729-
}
730-
if (miniLockZk.exists(miniZInstancePath, null) == null) {
731-
miniLockZk.create(miniZInstancePath, new byte[0], ZooUtil.PUBLIC, CreateMode.PERSISTENT);
732-
log.info("Created: {}", miniZInstancePath);
733-
}
725+
var zrw = miniLockZk.asReaderWriter();
726+
zrw.putPersistentData(miniZDirPath, new byte[0], NodeExistsPolicy.SKIP);
727+
zrw.putPersistentData(miniZInstancePath, new byte[0], NodeExistsPolicy.SKIP);
734728
} catch (KeeperException | InterruptedException e) {
735729
throw new IllegalStateException("Error creating path in ZooKeeper", e);
736730
}

0 commit comments

Comments
 (0)