You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/09/26 17:28:08 UTC

[GitHub] [ozone] smengcl commented on a diff in pull request #3725: HDDS-7178. [Multi-Tenant] Use optimistic read in Ranger background sync

smengcl commented on code in PR #3725:
URL: https://github.com/apache/ozone/pull/3725#discussion_r960218606


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestAuthorizerLockImpl.java:
##########
@@ -132,14 +132,15 @@ public void testUnlockWriteInOMRequestShouldNotThrowOnFollowerOMs() {
   }
 
   @Test
-  public void testIsWriteLockHeldByCurrentThread() throws IOException {
+  public void testIsWriteLockHeldByCurrentThread() throws IOException,
+      InterruptedException {
 
     final AuthorizerLock authorizerLock = new AuthorizerLockImpl();
 
     Assert.assertFalse(authorizerLock.isWriteLockHeldByCurrentThread());
 
     // Read lock does not affect the check
-    long readLockStamp = authorizerLock.tryReadLockThrowOnTimeout();
+    long readLockStamp = authorizerLock.tryReadLock(100);

Review Comment:
   nit
   ```suggestion
       long readLockStamp = authorizerLock.tryReadLock(100L);
   ```



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestAuthorizerLockImpl.java:
##########
@@ -153,4 +154,38 @@ public void testIsWriteLockHeldByCurrentThread() throws IOException {
     Assert.assertFalse(authorizerLock.isWriteLockHeldByCurrentThread());
     authorizerLock.unlockWrite(writeLockStamp);
   }
+
+  @Test
+  public void testOptimisticRead() throws Exception {
+    final AuthorizerLock authorizerLock = new AuthorizerLockImpl();
+
+    // With no competing operations, an optimistic read should be valid.
+    long stamp = authorizerLock.tryOptimisticReadThrowOnTimeout();
+    Assert.assertTrue(authorizerLock.validateOptimisticRead(stamp));
+
+    // With only competing reads, an optimistic read should be valid.
+    long optStamp = authorizerLock.tryOptimisticReadThrowOnTimeout();
+    long readStamp = authorizerLock.tryReadLock(100);

Review Comment:
   ```suggestion
       long readStamp = authorizerLock.tryReadLock(100L);
   ```



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org