ctubbsii commented on a change in pull request #2175:
URL: https://github.com/apache/accumulo/pull/2175#discussion_r657293548



##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java
##########
@@ -153,6 +155,58 @@ public static void unreserveHdfsDirectory(Manager env, 
String directory, long ti
         String.format("%016x", tid));
   }
 
+  private static boolean hasReadLock(ServerContext context, AbstractId<?> id, 
long tid)
+      throws KeeperException, InterruptedException {
+    byte[] lockData = String.format("%016x", tid).getBytes(UTF_8);
+    var fLockPath =
+        FateLock.path(context.getZooKeeperRoot() + Constants.ZTABLE_LOCKS + 
"/" + id.canonical());
+    FateLock qlock = new FateLock(context.getZooReaderWriter(), fLockPath);
+    Lock lock = DistributedReadWriteLock.recoverLock(qlock, lockData);
+    if (lock == null) {
+      return false;
+    } else if (lock instanceof ReadLock) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  public static boolean hasNamespaceReadLock(Manager env, NamespaceId nsId, 
long tid)
+      throws KeeperException, InterruptedException {
+    return hasReadLock(env.getContext(), nsId, tid);
+  }
+
+  public static boolean hasTableReadLock(Manager env, TableId tableId, long 
tid)
+      throws KeeperException, InterruptedException {
+    return hasReadLock(env.getContext(), tableId, tid);
+  }
+
+  private static boolean hasWriteLock(ServerContext context, AbstractId<?> id, 
long tid)
+      throws KeeperException, InterruptedException {
+    byte[] lockData = String.format("%016x", tid).getBytes(UTF_8);
+    var fLockPath =
+        FateLock.path(context.getZooKeeperRoot() + Constants.ZTABLE_LOCKS + 
"/" + id.canonical());
+    FateLock qlock = new FateLock(context.getZooReaderWriter(), fLockPath);
+    Lock lock = DistributedReadWriteLock.recoverLock(qlock, lockData);
+    if (lock == null) {
+      return false;
+    } else if (lock instanceof WriteLock) {
+      return true;
+    } else {
+      return false;
+    }
+  }

Review comment:
       Point is moot. See below conversation with Keith.




-- 
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:
[email protected]


Reply via email to