rakeshadr commented on code in PR #3271:
URL: https://github.com/apache/ozone/pull/3271#discussion_r843471208
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java:
##########
@@ -388,15 +405,22 @@ private void unlock(Resource resource, String
resourceName,
// TODO: Not checking release of higher order level lock happened while
// releasing lower order level lock, as for that we need counter for
// locks, as some locks support acquiring lock again.
+ boolean isWriteLocked = manager.isWriteLockedByCurrentThread(resourceName);
Review Comment:
Please move
`boolean isWriteLocked = manager.isWriteLockedByCurrentThread(resourceName);`
to the above TODO comment because thats talking about the lockFn.accept()
stetment.
##########
hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/lock/TestOzoneManagerLock.java:
##########
@@ -426,8 +444,58 @@ public void testReadLockConcurrentStats() throws
InterruptedException {
String readHeldStat = lock.getReadLockHeldTimeMsStat();
Assert.assertTrue(
- "Expected " + threadCount + " samples in " + readHeldStat,
+ "Expected " + threadCount +
+ " samples in readLockHeldTimeMsStat: " + readHeldStat,
readHeldStat.contains("Samples = " + threadCount));
+
+ String readWaitingStat = lock.getReadLockWaitingTimeMsStat();
+ Assert.assertTrue(
+ "Expected " + threadCount +
+ " samples in readLockWaitingTimeMsStat: " + readWaitingStat,
+ readWaitingStat.contains("Samples = " + threadCount));
+ }
+ }
+
+ @Test
+ public void testWriteLockConcurrentStats() throws InterruptedException {
Review Comment:
@tanvipenumudy Can you add a test case for mix of (synthetic)
readers/writers. Here you can have more readers than writers. For ex: 3 writers
and 10 readers.
`public void testSyntheticReadWriteLockConcurrentStats()`
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/lock/OzoneManagerLock.java:
##########
@@ -195,18 +202,28 @@ private boolean lock(Resource resource, String
resourceName,
}
}
- private void updateReadLockMetrics(Resource resource, String lockType,
+ private void updateReadLockMetrics(Resource resource,
long startWaitingTimeNanos) {
- if (lockType.equals(READ_LOCK)) {
- long readLockWaitingTimeNanos =
- Time.monotonicNowNanos() - startWaitingTimeNanos;
+ long readLockWaitingTimeNanos =
+ Time.monotonicNowNanos() - startWaitingTimeNanos;
- // Adds a snapshot to the metric readLockWaitingTimeMsStat.
- omLockMetrics.setReadLockWaitingTimeMsStat(
- TimeUnit.NANOSECONDS.toMillis(readLockWaitingTimeNanos));
+ // Adds a snapshot to the metric readLockWaitingTimeMsStat.
+ omLockMetrics.setReadLockWaitingTimeMsStat(
+ TimeUnit.NANOSECONDS.toMillis(readLockWaitingTimeNanos));
- resource.setStartHeldTimeNanos(Time.monotonicNowNanos());
- }
+ resource.setStartHeldTimeNanos(Time.monotonicNowNanos());
+ }
+
+ private void updateWriteLockMetrics(Resource resource,
+ long startWaitingTimeNanos) {
+ long writeLockWaitingTimeNanos =
+ Time.monotonicNowNanos() - startWaitingTimeNanos;
+
+ // Adds a snapshot to the metric writeLockWaitingTimeMsStat.
+ omLockMetrics.setWriteLockWaitingTimeMsStat(
+ TimeUnit.NANOSECONDS.toMillis(writeLockWaitingTimeNanos));
+
+ resource.setStartHeldTimeNanos(Time.monotonicNowNanos());
Review Comment:
`resource.setStartHeldTimeNanos(Time.monotonicNowNanos());`
```
OzoneManagerLock.java
void setStartHeldTimeNanos(long startHeldTimeNanos) {
readLockTimeStampNanos.get().setStartHeldTimeNanos(startHeldTimeNanos);
}
```
Its overwriting the held time for the read metrics. Please create a separate
var `writeLockTimeStampNanos`. Since we have plan to allow multiple writers
eventually(long term gaol) on disjoint OBS/FSO paths, we need to use
`ThreadLocal<LockUsageInfo> writeLockTimeStampNanos`, so that we keep track of
multiple writer threads stats.
--
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]