You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2021/01/12 18:34:54 UTC
[GitHub] [accumulo] EdColeman commented on a change in pull request #1866: Add a UUID to the server's ZooLock
EdColeman commented on a change in pull request #1866:
URL: https://github.com/apache/accumulo/pull/1866#discussion_r555989511
##########
File path: core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
##########
@@ -139,26 +144,66 @@ public synchronized boolean tryLock(LockWatcher lw, byte[] data)
return false;
}
+ private static void sortChildrenByLockPrefix(List<String> children) {
+ Collections.sort(children, new Comparator<String>() {
+ @Override
+ public int compare(String o1, String o2) {
+
+ // Lock should be of the form:
+ // zlock#UUID#sequenceNumber
+ // Example:
+ // zlock#44755fbe-1c9e-40b3-8458-03abaf950d7e#0000000000
+
+ boolean lValid = true;
+ if (o1.length() <= 43) {
+ lValid = false;
+ }
+ boolean rValid = true;
+ if (o2.length() <= 43) {
+ rValid = false;
+ }
+ // Make any invalid's sort last (higher)
+ if (lValid && rValid) {
+ int leftIdx = o1.lastIndexOf('#');
+ int rightIdx = o2.lastIndexOf('#');
+ return Integer.compare(Integer.parseInt(o1.substring(leftIdx)),
+ Integer.parseInt(o2.substring(rightIdx)));
+ } else if (!lValid && rValid) {
Review comment:
This should be able to be a string compare - zookeeper pads the sequence number with 0's (from zookeerer docs:
`The counter has a format of %010d -- that is 10 digits with 0 (zero) padding`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org