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

yongzao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new fd3797797a0 Remove extra user caching for REST services and migrate to 
the unified user check cache. (#17321)
fd3797797a0 is described below

commit fd3797797a08b04d2566b08009892c8547d60b27
Author: wenyanshi-123 <[email protected]>
AuthorDate: Fri Mar 20 09:51:24 2026 +0800

    Remove extra user caching for REST services and migrate to the unified user 
check cache. (#17321)
---
 external-service-impl/rest/pom.xml                 | 12 -----
 .../rest/protocol/filter/AuthorizationFilter.java  | 10 +---
 .../iotdb/rest/protocol/filter/UserCache.java      | 57 ----------------------
 .../src/test/resources/iotdb-common.properties     |  9 ----
 .../db/conf/rest/IoTDBRestServiceDescriptor.java   | 11 -----
 .../src/test/resources/iotdb-common.properties     |  9 ----
 .../src/test/resources/iotdb-system.properties     |  9 ----
 .../conf/iotdb-system.properties.template          | 15 ------
 8 files changed, 2 insertions(+), 130 deletions(-)

diff --git a/external-service-impl/rest/pom.xml 
b/external-service-impl/rest/pom.xml
index a5a1d76a1b2..63b2443a8e0 100644
--- a/external-service-impl/rest/pom.xml
+++ b/external-service-impl/rest/pom.xml
@@ -132,18 +132,6 @@
             <artifactId>slf4j-api</artifactId>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>com.github.ben-manes.caffeine</groupId>
-            <artifactId>caffeine</artifactId>
-            <scope>provided</scope>
-            <exclusions>
-                <!-- version conflicts with checker-qual in guava -->
-                <exclusion>
-                    <groupId>org.checkerframework</groupId>
-                    <artifactId>checker-qual</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>org.apache.iotdb</groupId>
             <artifactId>service-rpc</artifactId>
diff --git 
a/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
 
b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
index a31e5b953ab..a62a402e3d2 100644
--- 
a/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
+++ 
b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
@@ -47,7 +47,6 @@ import java.util.UUID;
 @Provider
 public class AuthorizationFilter implements ContainerRequestFilter, 
ContainerResponseFilter {
 
-  private final UserCache userCache = UserCache.getInstance();
   IoTDBRestServiceConfig config = 
IoTDBRestServiceDescriptor.getInstance().getConfig();
 
   private static final SessionManager SESSION_MANAGER = 
SessionManager.getInstance();
@@ -85,14 +84,9 @@ public class AuthorizationFilter implements 
ContainerRequestFilter, ContainerRes
       containerRequestContext.abortWith(resp);
       return;
     }
-    User user = userCache.getUser(authorizationHeader);
+    User user = checkLogin(containerRequestContext, authorizationHeader);
     if (user == null) {
-      user = checkLogin(containerRequestContext, authorizationHeader);
-      if (user == null) {
-        return;
-      } else {
-        userCache.setUser(authorizationHeader, user);
-      }
+      return;
     }
     String sessionid = UUID.randomUUID().toString();
     if (SESSION_MANAGER.getCurrSession() == null) {
diff --git 
a/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
 
b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
deleted file mode 100644
index 8c8a55f25b5..00000000000
--- 
a/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.iotdb.rest.protocol.filter;
-
-import org.apache.iotdb.db.conf.rest.IoTDBRestServiceConfig;
-import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-
-import java.util.concurrent.TimeUnit;
-
-public class UserCache {
-  private static final IoTDBRestServiceConfig CONFIG =
-      IoTDBRestServiceDescriptor.getInstance().getConfig();
-  private final Cache<String, User> cache;
-
-  private UserCache() {
-    cache =
-        Caffeine.newBuilder()
-            .initialCapacity(CONFIG.getCacheInitNum())
-            .maximumSize(CONFIG.getCacheMaxNum())
-            .expireAfterWrite(CONFIG.getCacheExpireInSeconds(), 
TimeUnit.SECONDS)
-            .build();
-  }
-
-  public static UserCache getInstance() {
-    return UserCacheHolder.INSTANCE;
-  }
-
-  public User getUser(String key) {
-    return cache.getIfPresent(key);
-  }
-
-  public void setUser(String key, User user) {
-    cache.put(key, user);
-  }
-
-  private static class UserCacheHolder {
-    private static final UserCache INSTANCE = new UserCache();
-  }
-}
diff --git a/iotdb-client/session/src/test/resources/iotdb-common.properties 
b/iotdb-client/session/src/test/resources/iotdb-common.properties
index 5019b199d1e..965b3c010ed 100644
--- a/iotdb-client/session/src/test/resources/iotdb-common.properties
+++ b/iotdb-client/session/src/test/resources/iotdb-common.properties
@@ -33,15 +33,6 @@ enable_rest_service=true
 # Whether to display rest service interface information through swagger. eg: 
http://ip:port/swagger.json
 # enable_swagger=false
 
-# the expiration time of the user login information cache (in seconds)
-# cache_expire_in_seconds=28800
-
-# maximum number of users can be stored in the user login cache.
-# cache_max_num=100
-
-# init capacity of users can be stored in the user login cache.
-# cache_init_num=10
-
 # is SSL enabled
 # enable_https=false
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
index 826c0fbdb01..c4f9d131de9 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java
@@ -111,17 +111,6 @@ public class IoTDBRestServiceDescriptor {
         Integer.parseInt(
             trimProperties.getProperty(
                 "idle_timeout_in_seconds", 
Integer.toString(conf.getIdleTimeoutInSeconds()))));
-    conf.setCacheExpireInSeconds(
-        Integer.parseInt(
-            trimProperties.getProperty(
-                "cache_expire_in_seconds", 
Integer.toString(conf.getCacheExpireInSeconds()))));
-    conf.setCacheInitNum(
-        Integer.parseInt(
-            trimProperties.getProperty(
-                "cache_init_num", Integer.toString(conf.getCacheInitNum()))));
-    conf.setCacheMaxNum(
-        Integer.parseInt(
-            trimProperties.getProperty("cache_max_num", 
Integer.toString(conf.getCacheMaxNum()))));
   }
 
   /**
diff --git a/iotdb-core/datanode/src/test/resources/iotdb-common.properties 
b/iotdb-core/datanode/src/test/resources/iotdb-common.properties
index fd24dc22d66..1053eaafa2d 100644
--- a/iotdb-core/datanode/src/test/resources/iotdb-common.properties
+++ b/iotdb-core/datanode/src/test/resources/iotdb-common.properties
@@ -33,15 +33,6 @@ enable_rest_service=true
 # the default row limit to a REST query response when the rowSize parameter is 
not given in request
 # rest_query_default_row_size_limit=10000
 
-# the expiration time of the user login information cache (in seconds)
-# cache_expire_in_seconds=28800
-
-# maximum number of users can be stored in the user login cache.
-# cache_max_num=100
-
-# init capacity of users can be stored in the user login cache.
-# cache_init_num=10
-
 # is SSL enabled
 # enable_https=false
 
diff --git a/iotdb-core/datanode/src/test/resources/iotdb-system.properties 
b/iotdb-core/datanode/src/test/resources/iotdb-system.properties
index 9bf298a2cf0..ce0ecff34f3 100644
--- a/iotdb-core/datanode/src/test/resources/iotdb-system.properties
+++ b/iotdb-core/datanode/src/test/resources/iotdb-system.properties
@@ -50,15 +50,6 @@ enable_rest_service=true
 # the default row limit to a REST query response when the rowSize parameter is 
not given in request
 # rest_query_default_row_size_limit=10000
 
-# the expiration time of the user login information cache (in seconds)
-# cache_expire_in_seconds=28800
-
-# maximum number of users can be stored in the user login cache.
-# cache_max_num=100
-
-# init capacity of users can be stored in the user login cache.
-# cache_init_num=10
-
 # is SSL enabled
 # enable_https=false
 
diff --git 
a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
 
b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
index d89566013fd..fedaa5ab43b 100644
--- 
a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
+++ 
b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
@@ -584,21 +584,6 @@ enable_swagger=false
 # Datatype: int
 rest_query_default_row_size_limit=10000
 
-# the expiration time of the user login information cache (in seconds)
-# effectiveMode: restart
-# Datatype: int
-cache_expire_in_seconds=28800
-
-# maximum number of users can be stored in the user login cache.
-# effectiveMode: restart
-# Datatype: int
-cache_max_num=100
-
-# init capacity of users can be stored in the user login cache.
-# effectiveMode: restart
-# Datatype: int
-cache_init_num=10
-
 # Is client authentication required
 # effectiveMode: restart
 # Datatype: boolean

Reply via email to