smengcl commented on code in PR #8446: URL: https://github.com/apache/ozone/pull/8446#discussion_r2098763314
########## hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java: ########## @@ -317,75 +331,46 @@ private void updateWriteLockMetrics(LeveledResource resource, // Adds a snapshot to the metric writeLockWaitingTimeMsStat. omLockMetrics.setWriteLockWaitingTimeMsStat( TimeUnit.NANOSECONDS.toMillis(writeLockWaitingTimeNanos)); - updateProcessingDetails(Timing.LOCKWAIT, writeLockWaitingTimeNanos); + updateProcessingDetails(resourcelockMap.get(resource.getClass()).getValue(), Timing.LOCKWAIT, + writeLockWaitingTimeNanos); - resource.setStartWriteHeldTimeNanos(Time.monotonicNowNanos()); + resource.getResourceManager().setStartWriteHeldTimeNanos(Time.monotonicNowNanos()); } } - private String getErrorMessage(LeveledResource resource) { + private String getErrorMessage(Resource resource) { return "Thread '" + Thread.currentThread().getName() + "' cannot " + - "acquire " + resource.name + " lock while holding " + + "acquire " + resource.getName() + " lock while holding " + getCurrentLocks().toString() + " lock(s)."; } @VisibleForTesting List<String> getCurrentLocks() { - List<String> currentLocks = new ArrayList<>(); - short lockSetVal = lockSet.get(); - for (LeveledResource value : LeveledResource.values()) { - if (value.isLevelLocked(lockSetVal)) { - currentLocks.add(value.getName()); - } - } - return currentLocks; + return resourcelockMap.values().stream().map(Pair::getValue) + .flatMap(i -> ((ResourceLockManager<? extends Resource>)i).getCurrentLockedResources()) Review Comment: nit ```suggestion .flatMap(rlm -> ((ResourceLockManager<? extends Resource>) rlm).getCurrentLockedResources()) ``` -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org