From 81533c4e40f2139fdd2e6f804f4edb67ed7ee4a8 Mon Sep 17 00:00:00 2001 From: xiaohu-liu <260304003@qq.com> Date: Mon, 30 Oct 2023 15:35:36 +0800 Subject: [PATCH] Fix the time check logic for judging stale client channels to be inactive --- .../authentication/DefaultAuthenticationServer.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dora/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java b/dora/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java index cf8b1704c028..d298b27c3b75 100644 --- a/dora/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java +++ b/dora/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java @@ -26,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @@ -160,12 +161,12 @@ public void close() { * stale. */ private void cleanupStaleClients() { - LocalTime cleanupTime = LocalTime.now(); + LocalDateTime cleanupTime = LocalDateTime.now(); LOG.debug("Starting cleanup authentication registry at {}", cleanupTime); // Get a list of stale clients under read lock. List staleChannels = new ArrayList<>(); for (Map.Entry clientEntry : mChannels.entrySet()) { - LocalTime lat = clientEntry.getValue().getLastAccessTime(); + LocalDateTime lat = clientEntry.getValue().getLastAccessTime(); if (lat.plusSeconds(mCleanupIntervalMs / 1000).isBefore(cleanupTime)) { staleChannels.add(clientEntry.getKey()); } @@ -201,7 +202,7 @@ protected void checkSupported(AuthType authType) { * and Sasl objects per channel. */ class AuthenticatedChannelInfo { - private LocalTime mLastAccessTime; + private LocalDateTime mLastAccessTime; private AuthenticatedUserInfo mUserInfo; private AuthenticatedChannelServerDriver mSaslServerDriver; @@ -213,17 +214,17 @@ public AuthenticatedChannelInfo(AuthenticatedUserInfo userInfo, AuthenticatedChannelServerDriver saslServerDriver) { mUserInfo = userInfo; mSaslServerDriver = saslServerDriver; - mLastAccessTime = LocalTime.now(); + mLastAccessTime = LocalDateTime.now(); } private synchronized void updateLastAccessTime() { - mLastAccessTime = LocalTime.now(); + mLastAccessTime = LocalDateTime.now(); } /** * @return the last access time */ - public synchronized LocalTime getLastAccessTime() { + public synchronized LocalDateTime getLastAccessTime() { return mLastAccessTime; }