This is an automated email from the ASF dual-hosted git repository.
jackietien 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 db28f95e901 Add method to convert author type
db28f95e901 is described below
commit db28f95e90180e2ccfc1f523c7b0e55704c9ee91
Author: shuwenwei <[email protected]>
AuthorDate: Sat Oct 11 10:52:04 2025 +0800
Add method to convert author type
---
.../confignode/persistence/auth/AuthorInfo.java | 42 +++++++++++++++++++++
.../thrift/ConfigNodeRPCServiceProcessor.java | 43 ++++------------------
2 files changed, 49 insertions(+), 36 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 f1248942ebe..57133e6cb2b 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
@@ -30,12 +30,15 @@ import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.commons.utils.TestOnly;
+import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlanType;
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorPlan;
import
org.apache.iotdb.confignode.consensus.request.write.auth.AuthorRelationalPlan;
import org.apache.iotdb.confignode.consensus.request.write.auth.AuthorTreePlan;
import org.apache.iotdb.confignode.consensus.response.auth.PermissionInfoResp;
import org.apache.iotdb.confignode.rpc.thrift.TAuthizedPatternTreeResp;
import org.apache.iotdb.confignode.rpc.thrift.TPermissionInfoResp;
+import org.apache.iotdb.db.queryengine.plan.relational.type.AuthorRType;
+import org.apache.iotdb.db.queryengine.plan.statement.AuthorType;
import org.apache.thrift.TException;
import org.slf4j.Logger;
@@ -63,6 +66,45 @@ public class AuthorInfo implements SnapshotProcessor {
}
}
+ public static ConfigPhysicalPlanType
getConfigPhysicalPlanTypeFromAuthorType(int authorType) {
+ ConfigPhysicalPlanType configPhysicalPlanType;
+ if (authorType == AuthorType.RENAME_USER.ordinal()) {
+ configPhysicalPlanType = ConfigPhysicalPlanType.RenameUser;
+ } else {
+ configPhysicalPlanType =
+ ConfigPhysicalPlanType.values()[authorType +
ConfigPhysicalPlanType.CreateUser.ordinal()];
+ switch (configPhysicalPlanType) {
+ case UpdateUser:
+ configPhysicalPlanType = ConfigPhysicalPlanType.UpdateUserV2;
+ break;
+ case DropUser:
+ configPhysicalPlanType = ConfigPhysicalPlanType.DropUserV2;
+ break;
+ }
+ }
+ return configPhysicalPlanType;
+ }
+
+ public static ConfigPhysicalPlanType
getConfigPhysicalPlanTypeFromAuthorRType(int authorRType) {
+ ConfigPhysicalPlanType configPhysicalPlanType;
+ if (authorRType == AuthorRType.RENAME_USER.ordinal()) {
+ configPhysicalPlanType = ConfigPhysicalPlanType.RRenameUser;
+ } else {
+ configPhysicalPlanType =
+ ConfigPhysicalPlanType.values()[
+ authorRType + ConfigPhysicalPlanType.RCreateUser.ordinal()];
+ switch (configPhysicalPlanType) {
+ case RUpdateUser:
+ configPhysicalPlanType = ConfigPhysicalPlanType.RUpdateUserV2;
+ break;
+ case RDropUser:
+ configPhysicalPlanType = ConfigPhysicalPlanType.RDropUserV2;
+ break;
+ }
+ }
+ return configPhysicalPlanType;
+ }
+
public void setAuthorQueryPlanExecutor(IAuthorPlanExecutor
authorPlanExecutor) {
this.authorPlanExecutor = authorPlanExecutor;
}
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 f06bc116df0..0f4a1645d44 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
@@ -83,6 +83,7 @@ import
org.apache.iotdb.confignode.consensus.response.ttl.ShowTTLResp;
import org.apache.iotdb.confignode.manager.ConfigManager;
import org.apache.iotdb.confignode.manager.consensus.ConsensusManager;
import org.apache.iotdb.confignode.manager.schema.ClusterSchemaManager;
+import org.apache.iotdb.confignode.persistence.auth.AuthorInfo;
import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
import org.apache.iotdb.confignode.rpc.thrift.TAINodeConfigurationResp;
import org.apache.iotdb.confignode.rpc.thrift.TAINodeRegisterReq;
@@ -635,22 +636,8 @@ public class ConfigNodeRPCServiceProcessor implements
IConfigNodeRPCService.Ifac
if (req.getAuthorType() < 0 || req.getAuthorType() >=
AuthorType.values().length) {
throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
}
- ConfigPhysicalPlanType configPhysicalPlanType;
- if (req.getAuthorType() == AuthorType.RENAME_USER.ordinal()) {
- configPhysicalPlanType = ConfigPhysicalPlanType.RenameUser;
- } else {
- configPhysicalPlanType =
- ConfigPhysicalPlanType.values()[
- req.getAuthorType() +
ConfigPhysicalPlanType.CreateUser.ordinal()];
- switch (configPhysicalPlanType) {
- case UpdateUser:
- configPhysicalPlanType = ConfigPhysicalPlanType.UpdateUserV2;
- break;
- case DropUser:
- configPhysicalPlanType = ConfigPhysicalPlanType.DropUserV2;
- break;
- }
- }
+ ConfigPhysicalPlanType configPhysicalPlanType =
+
AuthorInfo.getConfigPhysicalPlanTypeFromAuthorType(req.getAuthorType());
return configManager.operatePermission(
new AuthorTreePlan(
configPhysicalPlanType,
@@ -674,8 +661,7 @@ public class ConfigNodeRPCServiceProcessor implements
IConfigNodeRPCService.Ifac
(PermissionInfoResp)
configManager.queryPermission(
new AuthorTreePlan(
- ConfigPhysicalPlanType.values()[
- req.getAuthorType() +
ConfigPhysicalPlanType.CreateUser.ordinal()],
+
AuthorInfo.getConfigPhysicalPlanTypeFromAuthorType(req.getAuthorType()),
req.getUserName(),
req.getRoleName(),
req.getPassword(),
@@ -698,22 +684,8 @@ public class ConfigNodeRPCServiceProcessor implements
IConfigNodeRPCService.Ifac
if (req.getAuthorType() < 0 || req.getAuthorType() >=
AuthorRType.values().length) {
throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
}
- ConfigPhysicalPlanType configPhysicalPlanType;
- if (req.getAuthorType() == AuthorRType.RENAME_USER.ordinal()) {
- configPhysicalPlanType = ConfigPhysicalPlanType.RRenameUser;
- } else {
- configPhysicalPlanType =
- ConfigPhysicalPlanType.values()[
- req.getAuthorType() +
ConfigPhysicalPlanType.RCreateUser.ordinal()];
- switch (configPhysicalPlanType) {
- case RUpdateUser:
- configPhysicalPlanType = ConfigPhysicalPlanType.RUpdateUserV2;
- break;
- case RDropUser:
- configPhysicalPlanType = ConfigPhysicalPlanType.RDropUserV2;
- break;
- }
- }
+ ConfigPhysicalPlanType configPhysicalPlanType =
+
AuthorInfo.getConfigPhysicalPlanTypeFromAuthorRType(req.getAuthorType());
return configManager.operatePermission(
new AuthorRelationalPlan(
configPhysicalPlanType,
@@ -737,8 +709,7 @@ public class ConfigNodeRPCServiceProcessor implements
IConfigNodeRPCService.Ifac
(PermissionInfoResp)
configManager.queryPermission(
new AuthorRelationalPlan(
- ConfigPhysicalPlanType.values()[
- req.getAuthorType() +
ConfigPhysicalPlanType.RCreateUser.ordinal()],
+
AuthorInfo.getConfigPhysicalPlanTypeFromAuthorRType(req.getAuthorType()),
req.getUserName(),
req.getRoleName(),
req.getDatabase(),