Skip to content

Commit 4c3f83a

Browse files
committed
HADOOP-18852: DT performance improvement latest review incorporation
1 parent cd01f45 commit 4c3f83a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private String formatTokenId(TokenIdent id) {
121121
/**
122122
* Access to currentKey is protected by this object lock
123123
*/
124-
private volatile DelegationKey currentKey;
124+
private DelegationKey currentKey;
125125

126126
private final long keyUpdateInterval;
127127
private final long tokenMaxLifetime;
@@ -173,7 +173,7 @@ public void startThreads() throws IOException {
173173
Preconditions.checkState(!running);
174174
updateCurrentKey();
175175
this.apiLock.writeLock().lock();
176-
try{
176+
try {
177177
running = true;
178178
tokenRemoverThread = new Daemon(new ExpiredTokenRemover());
179179
tokenRemoverThread.start();
@@ -346,7 +346,7 @@ protected int getDelegationTokenSeqNum() {
346346
*/
347347
protected int incrementDelegationTokenSeqNum() {
348348
this.apiLock.writeLock().lock();
349-
try{
349+
try {
350350
return ++delegationTokenSequenceNumber;
351351
}finally {
352352
this.apiLock.writeLock().unlock();
@@ -502,8 +502,13 @@ private void updateCurrentKey() throws IOException {
502502
+ keyUpdateInterval + tokenMaxLifetime, generateSecret());
503503
//Log must be invoked outside the lock on 'this'
504504
logUpdateMasterKey(newKey);
505-
currentKey = newKey;
506-
storeDelegationKey(currentKey);
505+
this.apiLock.writeLock().lock();
506+
try {
507+
currentKey = newKey;
508+
storeDelegationKey(currentKey);
509+
}finally {
510+
this.apiLock.writeLock().unlock();
511+
}
507512
}
508513

509514
/**

0 commit comments

Comments
 (0)