This is an automated email from the ASF dual-hosted git repository. shuwenwei pushed a commit to branch addMethodToConvertAuthorType in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 95ec393ea4b5f2242dacebf585eb921ee729f18c Author: shuwenwei <[email protected]> AuthorDate: Fri Oct 10 19:36:24 2025 +0800 Add method to convert author type --- .../confignode/persistence/auth/AuthorInfo.java | 42 ++++++++++++++++++++++ .../thrift/ConfigNodeRPCServiceProcessor.java | 37 +++---------------- 2 files changed, 47 insertions(+), 32 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..28e9c8cce7e 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, @@ -698,22 +685,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,
