ctubbsii commented on a change in pull request #2175:
URL: https://github.com/apache/accumulo/pull/2175#discussion_r656618821
##########
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;
+ }
+ }
Review comment:
If you were to consolidate the two `hasReadLock` and `hasWriteLock`
methods, here is what might make sense:
```suggestion
private static boolean hasLock(ServerContext context, AbstractId<?> id,
long tid, boolean writeLock)
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);
return lock != null && (lock instanceof WriteLock) == writeLock;
}
```
--
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]