Skip to content

Commit c730786

Browse files
xiaoyuyaoajayydv
authored andcommitted
HDDS-1245. OM delegation expiration time should use Time.now instead … (#587)
Closes #587.
1 parent 2a54fea commit c730786

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ private void addToTokenStore(OzoneTokenIdentifier identifier, byte[] password)
158158
*/
159159
private void updateIdentifierDetails(OzoneTokenIdentifier identifier) {
160160
int sequenceNum;
161-
long now = Time.monotonicNow();
161+
long now = Time.now();
162162
sequenceNum = incrementDelegationTokenSeqNum();
163163
identifier.setIssueDate(now);
164164
identifier.setMasterKeyId(getCurrentKey().getKeyId());
165165
identifier.setSequenceNumber(sequenceNum);
166-
identifier.setMaxDate(Time.monotonicNow() + getTokenMaxLifetime());
166+
identifier.setMaxDate(now + getTokenMaxLifetime());
167167
identifier.setOmCertSerialId(getOmCertificateSerialId());
168168
}
169169

@@ -198,7 +198,7 @@ public synchronized long renewToken(Token<OzoneTokenIdentifier> token,
198198
formatTokenId(id), currentTokens.size());
199199
}
200200

201-
long now = Time.monotonicNow();
201+
long now = Time.now();
202202
if (id.getMaxDate() < now) {
203203
throw new OMException(renewer + " tried to renew an expired token "
204204
+ formatTokenId(id) + " max expiration date: "
@@ -293,7 +293,7 @@ public TokenInfo validateToken(OzoneTokenIdentifier identifier)
293293
throw new InvalidToken("token " + formatTokenId(identifier)
294294
+ " can't be found in cache");
295295
}
296-
long now = Time.monotonicNow();
296+
long now = Time.now();
297297
if (info.getRenewDate() < now) {
298298
throw new InvalidToken("token " + formatTokenId(identifier) + " is " +
299299
"expired, current time: " + Time.formatTime(now) +
@@ -329,7 +329,7 @@ public boolean verifySignature(OzoneTokenIdentifier identifier,
329329

330330
// TODO: handle roll private key/certificate
331331
private synchronized void removeExpiredKeys() {
332-
long now = Time.monotonicNow();
332+
long now = Time.now();
333333
for (Iterator<Map.Entry<Integer, OzoneSecretKey>> it = allKeys.entrySet()
334334
.iterator(); it.hasNext();) {
335335
Map.Entry<Integer, OzoneSecretKey> e = it.next();
@@ -447,7 +447,7 @@ public void stop() throws IOException {
447447
* Remove expired delegation tokens from cache and persisted store.
448448
*/
449449
private void removeExpiredToken() {
450-
long now = Time.monotonicNow();
450+
long now = Time.now();
451451
synchronized (this) {
452452
Iterator<Map.Entry<OzoneTokenIdentifier,
453453
TokenInfo>> i = currentTokens.entrySet().iterator();
@@ -480,7 +480,7 @@ public void run() {
480480
/ (60 * 1000) + " min(s)");
481481
try {
482482
while (isRunning()) {
483-
long now = Time.monotonicNow();
483+
long now = Time.now();
484484
if (lastTokenCacheCleanup + getTokenRemoverScanInterval()
485485
< now) {
486486
removeExpiredToken();

0 commit comments

Comments
 (0)