|
81 | 81 | import org.apache.accumulo.core.data.InstanceId;
|
82 | 82 | import org.apache.accumulo.core.data.TableId;
|
83 | 83 | 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; |
85 | 85 | import org.apache.accumulo.core.lock.ServiceLock;
|
86 | 86 | import org.apache.accumulo.core.lock.ServiceLock.AccumuloLockWatcher;
|
87 | 87 | import org.apache.accumulo.core.lock.ServiceLock.LockLossReason;
|
|
121 | 121 | import org.apache.hadoop.fs.Path;
|
122 | 122 | import org.apache.hadoop.hdfs.DFSConfigKeys;
|
123 | 123 | import org.apache.hadoop.hdfs.MiniDFSCluster;
|
124 |
| -import org.apache.zookeeper.CreateMode; |
125 | 124 | import org.apache.zookeeper.KeeperException;
|
126 | 125 | import org.slf4j.Logger;
|
127 | 126 | import org.slf4j.LoggerFactory;
|
@@ -723,14 +722,9 @@ public void failedToAcquireLock(Exception e) {
|
723 | 722 | String miniZDirPath =
|
724 | 723 | miniZInstancePath.substring(0, miniZInstancePath.indexOf("/" + miniUUID.toString()));
|
725 | 724 | 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); |
734 | 728 | } catch (KeeperException | InterruptedException e) {
|
735 | 729 | throw new IllegalStateException("Error creating path in ZooKeeper", e);
|
736 | 730 | }
|
|
0 commit comments