EdColeman commented on a change in pull request #2324:
URL: https://github.com/apache/accumulo/pull/2324#discussion_r738498495
##########
File path:
core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReaderWriter.java
##########
@@ -124,6 +124,34 @@ public boolean putPersistentData(String zPath, byte[]
data, NodeExistsPolicy pol
e -> e.code() == Code.NONODE && policy == NodeExistsPolicy.OVERWRITE);
}
+ /**
+ * Overwrite a persistent node if the data version matches.
+ *
+ * @param zPath
+ * the zookeeper path
+ * @param data
+ * the byte array data
+ * @param expectedVersion
+ * the expected data version of the zookeeper node.
+ * @return true if the data was set, false if the version does not match
expected.
+ * @throws KeeperException
+ * if a KeeperException occurs (no node most likely)
+ * @throws InterruptedException
+ * if the zookeeper write is interrupted.
+ */
+ public boolean overwritePersistentData(String zPath, byte[] data, final int
expectedVersion)
Review comment:
The current code would make an extra ZK call to create - which in this
case the node must be there - or it should fail, the prop code uses a specific
init so that watchers are handled and I'm not sure that would hold if a variant
of putPersistent would use.
Having a specific method eliminates a ZK call.
--
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]