You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sh...@apache.org on 2025/10/11 11:11:30 UTC
(iotdb) branch fixAuthorTypeConversion created (now 5926ebe4bd9)
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a change to branch fixAuthorTypeConversion
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at 5926ebe4bd9 fix author type conversion
This branch includes the following new commits:
new 5926ebe4bd9 fix author type conversion
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: fix author type conversion
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a commit to branch fixAuthorTypeConversion
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5926ebe4bd9dc65c176f4c7139e4dfd9e6e5a30e
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Sat Oct 11 18:49:43 2025 +0800
fix author type conversion
---
.../confignode/persistence/auth/AuthorInfo.java | 17 +++-
.../thrift/ConfigNodeRPCServiceProcessor.java | 6 --
.../db/queryengine/plan/statement/AuthorType.java | 103 ++-------------------
3 files changed, 25 insertions(+), 101 deletions(-)
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
index 57133e6cb2b..06c564fd5ac 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
@@ -67,9 +67,22 @@ public class AuthorInfo implements SnapshotProcessor {
}
public static ConfigPhysicalPlanType getConfigPhysicalPlanTypeFromAuthorType(int authorType) {
+ if (authorType < 0) {
+ throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
+ }
ConfigPhysicalPlanType configPhysicalPlanType;
- if (authorType == AuthorType.RENAME_USER.ordinal()) {
- configPhysicalPlanType = ConfigPhysicalPlanType.RenameUser;
+ if (authorType >= AuthorType.RENAME_USER.ordinal()) {
+ AuthorType type = AuthorType.values()[authorType];
+ switch (type) {
+ case RENAME_USER:
+ return ConfigPhysicalPlanType.RenameUser;
+ case UPDATE_USER_MAX_SESSION:
+ return ConfigPhysicalPlanType.UpdateUserMaxSession;
+ case UPDATE_USER_MIN_SESSION:
+ return ConfigPhysicalPlanType.UpdateUserMinSession;
+ default:
+ throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
+ }
} else {
configPhysicalPlanType =
ConfigPhysicalPlanType.values()[authorType + ConfigPhysicalPlanType.CreateUser.ordinal()];
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
index 0f4a1645d44..d4b29a766d8 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
@@ -633,9 +633,6 @@ public class ConfigNodeRPCServiceProcessor implements IConfigNodeRPCService.Ifac
@Override
public TSStatus operatePermission(final TAuthorizerReq req) {
- if (req.getAuthorType() < 0 || req.getAuthorType() >= AuthorType.values().length) {
- throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
- }
ConfigPhysicalPlanType configPhysicalPlanType =
AuthorInfo.getConfigPhysicalPlanTypeFromAuthorType(req.getAuthorType());
return configManager.operatePermission(
@@ -654,9 +651,6 @@ public class ConfigNodeRPCServiceProcessor implements IConfigNodeRPCService.Ifac
@Override
public TAuthorizerResp queryPermission(final TAuthorizerReq req) {
- if (req.getAuthorType() < 0 || req.getAuthorType() >= AuthorType.values().length) {
- throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
- }
final PermissionInfoResp dataSet =
(PermissionInfoResp)
configManager.queryPermission(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
index 59949440950..94e1893b8d4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
@@ -19,7 +19,11 @@
package org.apache.iotdb.db.queryengine.plan.statement;
+// If you need to add a new type, you need to add it to the end because the ordinal will be used as
+// offset to calculate ConfigPhysicalPlanType
public enum AuthorType {
+ // The ConfigPhysicalPlanType in this part can be automatically converted according to the offset
+ // in this class
CREATE_USER,
CREATE_ROLE,
DROP_USER,
@@ -35,101 +39,14 @@ public enum AuthorType {
LIST_ROLE,
LIST_USER_PRIVILEGE,
LIST_ROLE_PRIVILEGE,
+
ACCOUNT_UNLOCK,
+
// Remind to renew the convert codes in ConfigNodeRPCServiceProcessor
+ // If the config node plan is involved, the type defined in following lines needs to manually add
+ // conversion logic
RENAME_USER,
+ UPDATE_USER_MAX_SESSION,
+ UPDATE_USER_MIN_SESSION,
;
-
- /**
- * deserialize short number.
- *
- * @param i short number
- * @return NamespaceType
- */
- public static AuthorType deserialize(short i) {
- switch (i) {
- case 0:
- return CREATE_USER;
- case 1:
- return CREATE_ROLE;
- case 2:
- return DROP_USER;
- case 3:
- return DROP_ROLE;
- case 4:
- return GRANT_ROLE;
- case 5:
- return GRANT_USER;
- case 6:
- return GRANT_USER_ROLE;
- case 7:
- return REVOKE_USER;
- case 8:
- return REVOKE_ROLE;
- case 9:
- return REVOKE_USER_ROLE;
- case 10:
- return UPDATE_USER;
- case 11:
- return LIST_USER;
- case 12:
- return LIST_ROLE;
- case 13:
- return LIST_USER_PRIVILEGE;
- case 14:
- return LIST_ROLE_PRIVILEGE;
- case 15:
- return RENAME_USER;
- case 16:
- return ACCOUNT_UNLOCK;
- default:
- return null;
- }
- }
-
- /**
- * serialize.
- *
- * @return short number
- */
- public short serialize() {
- switch (this) {
- case CREATE_USER:
- return 0;
- case CREATE_ROLE:
- return 1;
- case DROP_USER:
- return 2;
- case DROP_ROLE:
- return 3;
- case GRANT_ROLE:
- return 4;
- case GRANT_USER:
- return 5;
- case GRANT_USER_ROLE:
- return 6;
- case REVOKE_USER:
- return 7;
- case REVOKE_ROLE:
- return 8;
- case REVOKE_USER_ROLE:
- return 9;
- case UPDATE_USER:
- return 10;
- case LIST_USER:
- return 11;
- case LIST_ROLE:
- return 12;
- case LIST_USER_PRIVILEGE:
- return 13;
- case LIST_ROLE_PRIVILEGE:
- return 14;
- case RENAME_USER:
- return 15;
- case ACCOUNT_UNLOCK:
- return 16;
- default:
- return -1;
- }
- }
}