OneSizeFitsQuorum commented on code in PR #14813:
URL: https://github.com/apache/iotdb/pull/14813#discussion_r1950632418
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java:
##########
@@ -2876,6 +2878,50 @@ public SettableFuture<ConfigTaskResult> removeDataNode(
return future;
}
+ @Override
+ public SettableFuture<ConfigTaskResult> removeConfigNode(
+ final RemoveConfigNodeStatement removeConfigNodeStatement) {
+ final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+
+ int removeConfigNodeId = removeConfigNodeStatement.getNodeId();
+
+ LOGGER.info("Starting to remove ConfigNode with node-id {}",
removeConfigNodeId);
+ try (ConfigNodeClient configNodeClient =
+
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
+
+ TShowClusterResp showClusterResp = configNodeClient.showCluster();
+ List<TConfigNodeLocation> removeConfigNodeLocations =
+ showClusterResp.getConfigNodeList().stream()
+ .filter(node -> node.configNodeId == removeConfigNodeId)
+ .collect(Collectors.toList());
+ if (removeConfigNodeLocations.size() != 1) {
+ LOGGER.error(
+ "The ConfigNode to be removed is not in the cluster, or the input
format is incorrect.");
+ future.set(new ConfigTaskResult(TSStatusCode.REMOVE_CONFIGNODE_ERROR));
+ ;
Review Comment:
redundant
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java:
##########
@@ -1190,6 +1191,14 @@ public Node
visitRemoveDataNodeStatement(RelationalSqlParser.RemoveDataNodeState
return new RemoveDataNode(nodeIds);
}
+ @Override
+ public Node visitRemoveConfigNodeStatement(
+ RelationalSqlParser.RemoveConfigNodeStatementContext ctx) {
+ Integer nodeId =
+ Integer.parseInt(ctx.INTEGER_VALUE() == null ? "-1" :
ctx.INTEGER_VALUE().getText());
Review Comment:
Can it be null? If so, why we do not judge this in line 1187?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java:
##########
@@ -4226,6 +4227,13 @@ public Statement
visitRemoveDataNode(IoTDBSqlParser.RemoveDataNodeContext ctx) {
return new RemoveDataNodeStatement(dataNodeIDs);
}
+ @Override
+ public Statement
visitRemoveConfigNode(IoTDBSqlParser.RemoveConfigNodeContext ctx) {
Review Comment:
same as below
--
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]