This is an automated email from the ASF dual-hosted git repository.

zanderxu pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit e4885b02efc2f975e97347affa6d0a174cb4eb9c
Author: Yuanbo Liu <yua...@apache.org>
AuthorDate: Tue Apr 16 11:51:02 2024 +0800

    HDFS-17424. [FGL] DelegationTokenSecretManager supports fine-grained lock 
(#6696)
---
 .../security/token/delegation/DelegationTokenSecretManager.java  | 9 +++++----
 .../org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java     | 4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
index b89998d9895..5ac5d29d9a2 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/delegation/DelegationTokenSecretManager.java
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.Map.Entry;
 
+import org.apache.hadoop.hdfs.server.namenode.fgl.FSNamesystemLockMode;
 import org.apache.hadoop.util.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -372,7 +373,7 @@ protected void logUpdateMasterKey(DelegationKey key)
       // closes the edit log files. Doing this inside the
       // fsn lock will prevent being interrupted when stopping
       // the secret manager.
-      namesystem.readLockInterruptibly();
+      namesystem.readLockInterruptibly(FSNamesystemLockMode.FS);
       try {
         // this monitor isn't necessary if stopped while holding write lock
         // but for safety, guard against a stop with read lock.
@@ -383,7 +384,7 @@ protected void logUpdateMasterKey(DelegationKey key)
           namesystem.logUpdateMasterKey(key);
         }
       } finally {
-        namesystem.readUnlock("logUpdateMasterKey");
+        namesystem.readUnlock(FSNamesystemLockMode.FS, "logUpdateMasterKey");
       }
     } catch (InterruptedException ie) {
       // AbstractDelegationTokenManager may crash if an exception is thrown.
@@ -401,7 +402,7 @@ protected void logExpireToken(final 
DelegationTokenIdentifier dtId)
       // closes the edit log files. Doing this inside the
       // fsn lock will prevent being interrupted when stopping
       // the secret manager.
-      namesystem.readLockInterruptibly();
+      namesystem.readLockInterruptibly(FSNamesystemLockMode.FS);
       try {
         // this monitor isn't necessary if stopped while holding write lock
         // but for safety, guard against a stop with read lock.
@@ -412,7 +413,7 @@ protected void logExpireToken(final 
DelegationTokenIdentifier dtId)
           namesystem.logExpireDelegationToken(dtId);
         }
       } finally {
-        namesystem.readUnlock("logExpireToken");
+        namesystem.readUnlock(FSNamesystemLockMode.FS, "logExpireToken");
       }
     } catch (InterruptedException ie) {
       // AbstractDelegationTokenManager may crash if an exception is thrown.
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index a8347668dc0..d718d17ac8b 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -6516,7 +6516,7 @@ public void logUpdateMasterKey(DelegationKey key) {
       "the DT manager before entering safemode!";
     // edit log rolling is not thread-safe and must be protected by the
     // fsn lock.  not updating namespace so read lock is sufficient.
-    assert hasReadLock();
+    assert hasReadLock(FSNamesystemLockMode.FS);
     getEditLog().logUpdateMasterKey(key);
     getEditLog().logSync();
   }
@@ -6532,7 +6532,7 @@ public void 
logExpireDelegationToken(DelegationTokenIdentifier id) {
       "the DT manager before entering safemode!";
     // edit log rolling is not thread-safe and must be protected by the
     // fsn lock.  not updating namespace so read lock is sufficient.
-    assert hasReadLock();
+    assert hasReadLock(FSNamesystemLockMode.FS);
     // do not logSync so expiration edits are batched
     getEditLog().logCancelDelegationToken(id);
   }  


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to