This is an automated email from the ASF dual-hosted git repository.
yongzao pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 944002abbdc Remove extra user caching for REST services and migrate to
the unified user check cache. (#17324)
944002abbdc is described below
commit 944002abbdc0d1eb92dc626d74ebd6689e76fed8
Author: wenyanshi-123 <[email protected]>
AuthorDate: Fri Mar 20 12:15:07 2026 +0800
Remove extra user caching for REST services and migrate to the unified user
check cache. (#17324)
---
.../src/test/resources/iotdb-common.properties | 9 ----
.../db/conf/rest/IoTDBRestServiceDescriptor.java | 10 ----
.../protocol/rest/filter/AuthorizationFilter.java | 11 ++---
.../iotdb/db/protocol/rest/filter/UserCache.java | 57 ----------------------
.../src/test/resources/iotdb-common.properties | 9 ----
.../src/test/resources/iotdb-system.properties | 9 ----
.../conf/iotdb-system.properties.template | 15 ------
7 files changed, 3 insertions(+), 117 deletions(-)
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 2e9f49917f0..ee8ca0705b5 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
@@ -109,16 +109,6 @@ public class IoTDBRestServiceDescriptor {
Integer.parseInt(
properties.getProperty(
"idle_timeout_in_seconds",
Integer.toString(conf.getIdleTimeoutInSeconds()))));
- conf.setCacheExpireInSeconds(
- Integer.parseInt(
- properties.getProperty(
- "cache_expire_in_seconds",
Integer.toString(conf.getCacheExpireInSeconds()))));
- conf.setCacheInitNum(
- Integer.parseInt(
- properties.getProperty("cache_init_num",
Integer.toString(conf.getCacheInitNum()))));
- conf.setCacheMaxNum(
- Integer.parseInt(
- properties.getProperty("cache_max_num",
Integer.toString(conf.getCacheMaxNum()))));
}
/**
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java
index 53c825cb69c..878705ad0bc 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/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,15 +84,11 @@ 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) {
RestClientSession restClientSession = new RestClientSession(sessionid);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java
deleted file mode 100644
index f53273def2d..00000000000
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/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.db.protocol.rest.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-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 126feb4123d..e12f3d2ddc8 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
@@ -560,21 +560,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