liyuheng55555 commented on code in PR #14678:
URL: https://github.com/apache/iotdb/pull/14678#discussion_r1919745323
##########
iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4:
##########
@@ -464,7 +465,9 @@ migrateRegionStatement
: MIGRATE REGION regionId=INTEGER_VALUE FROM fromId=INTEGER_VALUE TO
toId=INTEGER_VALUE
;
-
+removeDataNodeStatement
+ : REMOVE DATANODE dataNodeId=INTEGER_VALUE (',' dataNodeId=INTEGER_VALUE)*
+ ;
Review Comment:
remove datanode**s** ?
##########
iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4:
##########
@@ -536,6 +536,11 @@ verifyConnection
: VERIFY CONNECTION (DETAILS)?
;
+// ---- Remove DataNode
+removeDataNode
+ : REMOVE DATANODE dataNodeId=INTEGER_LITERAL (COMMA
dataNodeId=INTEGER_LITERAL)*
Review Comment:
remove datanode**s**?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java:
##########
@@ -2773,6 +2779,62 @@ public SettableFuture<ConfigTaskResult> migrateRegion(
return future;
}
+ @Override
+ public SettableFuture<ConfigTaskResult> removeDataNode(
+ final RemoveDataNodeStatement removeDataNodeStatement) {
+ final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ try (ConfigNodeClient configNodeClient =
+
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
+ Set<Integer> nodeIds = removeDataNodeStatement.getNodeIds();
+
+ Set<Integer> validNodeIds =
+
configNodeClient.getDataNodeConfiguration(-1).getDataNodeConfigurationMap().keySet();
+
+ Set<Integer> invalidNodeIds = new HashSet<>(nodeIds);
+ invalidNodeIds.removeAll(validNodeIds);
+
+ if (!invalidNodeIds.isEmpty()) {
+ LOGGER.info("Cannot remove invalid nodeIds:{}", invalidNodeIds);
+ nodeIds.removeAll(invalidNodeIds);
+ }
+
+ LOGGER.info("Starting to remove DataNode with nodeIds: {}", nodeIds);
+
+ final Set<Integer> finalNodeIds = nodeIds;
+ List<TDataNodeLocation> removeDataNodeLocations =
+ configNodeClient
+ .getDataNodeConfiguration(-1)
+ .getDataNodeConfigurationMap()
+ .values()
+ .stream()
+ .map(TDataNodeConfiguration::getLocation)
+ .filter(location ->
finalNodeIds.contains(location.getDataNodeId()))
+ .collect(Collectors.toList());
+ LOGGER.info(
+ "Start to remove datanode, removed DataNodes endpoint: {}",
removeDataNodeLocations);
Review Comment:
It's not recommended to print TDataNodeLocation directly, because it's too
long.
Please consider RegionMaintainHandler.simplifiedLocation
##########
iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4:
##########
@@ -217,6 +217,14 @@ DATABASES
: D A T A B A S E S
;
+DATANODE
+ : D A T A N O D E
+ ;
+
+DATANODEADDRESS
+ : D A T A N O D E A D D R E S S
+ ;
Review Comment:
what's this
--
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]