kerneltime commented on code in PR #3424:
URL: https://github.com/apache/ozone/pull/3424#discussion_r877664452
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java:
##########
@@ -176,23 +182,11 @@ private boolean lock(Resource resource, String
resourceName,
LOG.error(errorMessage);
throw new RuntimeException(errorMessage);
} else {
- 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) &&
- manager.getReadHoldCount(resourceName) == 1) {
- updateReadLockMetrics(resource, startWaitingTimeNanos);
- }
- if (lockType.equals(WRITE_LOCK) &&
- (manager.getWriteHoldCount(resourceName) == 1) &&
- manager.isWriteLockedByCurrentThread(resourceName)) {
- updateWriteLockMetrics(resource, startWaitingTimeNanos);
+ if (!omLockMetricsCollectionEnabled) {
+ lockFn.accept(resourceName);
+ } else {
+ updateLockMetrics(resource, resourceName, lockFn, lockType);
Review Comment:
This code needs jumping around to figure out what is the exact set of
actions that will take place.
I would recommend, adding a wrapper that actually implements the check for
if lock metrics should be collected. The code here should just be lockFn.accept
-> measureAndAccept(lockFn, resource, resourceName, lockType). In the the
wrapper check if the flag is set.
--
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]