anuengineer commented on a change in pull request #949: HDDS-1672. Improve 
locking in OzoneManager.
URL: https://github.com/apache/hadoop/pull/949#discussion_r295898679
 
 

 ##########
 File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerLock.java
 ##########
 @@ -96,30 +112,39 @@ public OzoneManagerLock(Configuration conf) {
   }
 
   /**
-   * Acquires user lock on the given resource.
+   * Acquires S3 Bucket lock on the given resource.
    *
    * <p>If the lock is not available then the current thread becomes
-   * disabled for thread scheduling purposes and lies dormant until the
-   * lock has been acquired.
+   * disabled for thread scheduling purposes and lies dormant until the lock 
has
+   * been acquired.
    *
-   * @param user User on which the lock has to be acquired
+   * @param s3BucketName S3Bucket Name on which the lock has to be acquired
    */
-  public void acquireUserLock(String user) {
-    // Calling thread should not hold any volume or bucket lock.
-    if (hasAnyVolumeLock() || hasAnyBucketLock() || hasAnyS3Lock()) {
+  public void acquireS3BucketLock(String s3BucketName) {
+    // Calling thread should not hold any volume/bucket/user lock.
+
+    // Not added checks for prefix/s3 secret lock, as they will never be
+    // taken with s3Bucket Lock. In this way, we can avoid 2 checks every
+    // time we acquire s3Bucket lock.
+
+    // Or do we need to add this for future safe?
+
+    if (hasAnyVolumeLock() || hasAnyBucketLock() || hasAnyUserLock()) {
       throw new RuntimeException(
           "Thread '" + Thread.currentThread().getName() +
-              "' cannot acquire user lock" +
-              " while holding volume, bucket or S3 bucket lock(s).");
+              "' cannot acquire S3 bucket lock while holding Ozone " +
+              "Volume/Bucket/User lock(s).");
     }
-    manager.lock(OM_USER_PREFIX + user);
+    manager.lock(OM_S3_PREFIX + s3BucketName);
 
 Review comment:
   Let us commit this and I can push a patch that will remove the hash table 
and will use a bitmap -- I will also write benchmark for this lockmaanger 
function

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to