VGalaxies commented on code in PR #17780:
URL: https://github.com/apache/iotdb/pull/17780#discussion_r3371178923
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java:
##########
@@ -1733,6 +1736,35 @@ public TSStatus createTopic(TCreateTopicReq req) {
}
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ try {
+ final TopicMeta updatedTopicMeta =
+ configManager
+ .getSubscriptionManager()
+ .getSubscriptionCoordinator()
+ .buildAlteredTopicMeta(req);
+ if (updatedTopicMeta == null) {
+ return new TSStatus(TSStatusCode.ALTER_TOPIC_ERROR.getStatusCode())
+ .setMessage(
+ String.format(
+ "Failed to alter topic %s, the topic is not existed",
req.getTopicName()));
+ }
Review Comment:
Addressed in 82049d7b46. Moved this hard-coded ALTER TOPIC error message
into `ManagerMessages` for both en and zh locale sources.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,6 +151,25 @@ public TSStatus createTopic(TCreateTopicReq req) {
return status;
}
+ public TSStatus alterTopic(TAlterTopicReq req) {
+ final TSStatus status =
configManager.getProcedureManager().alterTopic(req);
+ if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.warn(
+ "Failed to alter topic {} with attributes {}, result status is {}.",
+ req.getTopicName(),
+ req.getTopicAttributes(),
+ status);
+ }
+ return status;
+ }
+
+ public TopicMeta buildAlteredTopicMeta(TAlterTopicReq req) {
+ final TopicMeta existedTopicMeta =
subscriptionInfo.deepCopyTopicMeta(req.getTopicName());
+ return existedTopicMeta == null
+ ? null
+ :
existedTopicMeta.deepCopyWithUpdatedAttributes(req.getTopicAttributes());
+ }
Review Comment:
Addressed in 82049d7b46. I added
`SubscriptionInfo#deepCopyTopicMetaWithUpdatedAttributes(...)`, so the
read-lock protected lookup and attribute merge now create one copied
`TopicMeta` instead of deep-copying twice in `SubscriptionCoordinator`.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java:
##########
@@ -4425,6 +4426,23 @@ public Statement
visitCreateTopic(IoTDBSqlParser.CreateTopicContext ctx) {
return createTopicStatement;
}
+ @Override
+ public Statement visitAlterTopic(IoTDBSqlParser.AlterTopicContext ctx) {
+ final AlterTopicStatement alterTopicStatement = new AlterTopicStatement();
+
+ if (ctx.topicName != null) {
+
alterTopicStatement.setTopicName(parseIdentifier(ctx.topicName.getText()));
+ } else {
+ throw new SemanticException(
+ "Not support for this sql in ALTER TOPIC, please enter topicName.");
+ }
Review Comment:
Addressed in 82049d7b46. Moved this parser error into
`DataNodeQueryMessages` for both en and zh locale sources.
##########
iotdb-client/subscription/src/main/java/org/apache/iotdb/session/subscription/ISubscriptionTableSession.java:
##########
@@ -99,6 +99,49 @@ void createTopic(final String topicName, final Properties
properties)
void createTopicIfNotExists(final String topicName, final Properties
properties)
throws IoTDBConnectionException, StatementExecutionException;
+ /**
+ * Alters a topic with the specified properties.
+ *
+ * @param topicName If the topic name contains single quotes, the passed
parameter needs to be
+ * enclosed in backticks.
+ * @param properties A {@link Properties} object containing the topic
properties to alter.
+ * @throws IoTDBConnectionException If a connection issue occurs.
+ * @throws StatementExecutionException If the SQL statement execution fails.
+ */
+ void alterTopic(final String topicName, final Properties properties)
+ throws IoTDBConnectionException, StatementExecutionException;
Review Comment:
Addressed in 82049d7b46. The public session `alterTopic(topicName,
properties)` now rejects `owner-id`, `owner-epoch`, and
`owner-lease-expire-time-ms`; owner fields are only allowed through the
internal path used by `alterTopicOwner(...)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]