bharatviswa504 commented on a change in pull request #949: HDDS-1672. Improve
locking in OzoneManager.
URL: https://github.com/apache/hadoop/pull/949#discussion_r295952709
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerLock.java
##########
@@ -258,12 +348,61 @@ public void acquirePrefixLock(String prefixPath) {
myLocks.get().get(PREFIX_LOCK).incrementAndGet();
}
- private boolean hasAnyPrefixLock() {
- return myLocks.get().get(PREFIX_LOCK).get() != 0;
- }
-
+ /**
+ * Releases the prefix lock on given resource.
+ */
public void releasePrefixLock(String prefixPath) {
manager.unlock(prefixPath);
myLocks.get().get(PREFIX_LOCK).decrementAndGet();
}
+
+ /**
+ * Returns true if the current thread holds any volume lock.
+ * @return true if current thread holds volume lock, else false
+ */
+ private boolean hasAnyVolumeLock() {
+ return myLocks.get().get(VOLUME_LOCK).get() != 0;
+ }
+
+ /**
+ * Returns true if the current thread holds any bucket lock.
+ * @return true if current thread holds bucket lock, else false
+ */
+ private boolean hasAnyBucketLock() {
+ return myLocks.get().get(BUCKET_LOCK).get() != 0;
+ }
+
+ /**
+ * Returns true if the current thread holds any s3 bucket lock.
+ * @return true if current thread holds s3 bucket lock, else false
+ */
+ private boolean hasAnyS3BucketLock() {
+ return myLocks.get().get(S3_BUCKET_LOCK).get() != 0;
+ }
+
+ /**
+ * Returns true if the current thread holds any user lock.
+ * @return true if current thread holds user lock, else false
+ */
+ private boolean hasAnyUserLock() {
+ return myLocks.get().get(USER_LOCK).get() != 0;
Review comment:
Yes, added a call for hasAnyUserLock() in acquireUserLock() so that if some
one is trying to acquire multiple user locks, he will immediately fail with
RunTimeException. As said in code comments in acquireUserLock() this is a
protection logic, in avoiding users do that.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]