rakeshadr commented on code in PR #3424:
URL: https://github.com/apache/ozone/pull/3424#discussion_r876901870


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java:
##########
@@ -202,6 +196,26 @@ private boolean lock(Resource resource, String 
resourceName,
     }
   }
 
+  private void updateLockMetrics(Resource resource, String resourceName,
+                         Consumer<String> lockFn, String lockType) {
+    long startWaitingTimeNanos = Time.monotonicNowNanos();
+    lockFn.accept(resourceName);
+
+    /**
+     *  read/write lock hold count helps in metrics updation only once in case
+     *  of reentrant locks.
+     */
+    if (lockType.equals(READ_LOCK) &&

Review Comment:
   Can we make this more readable, something like to use a switch case:
   
   ```
   if (omLockMetricsCollectionEnabled) {
     switch (lockType) {
     case READ_LOCK:
       updateReadLockMetrics(resource, resourceName, startWaitingTimeNanos);
       break;
     case WRITE_LOCK:
       updateWriteLockMetrics(resource, resourceName, startWaitingTimeNanos);
       break;
     default:
       break;
     }
   } else {
     lockFn.accept(resourceName);
   }
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to