This is an automated email from the ASF dual-hosted git repository.
tanxinyu 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 387b4bf3e43 [remove datanode] Identify and display invalid nodes
before removing #13987
387b4bf3e43 is described below
commit 387b4bf3e4318000ddf041b66a26c6244636dd41
Author: Xiangpeng Hu <[email protected]>
AuthorDate: Tue Nov 5 18:28:54 2024 +0800
[remove datanode] Identify and display invalid nodes before removing #13987
---
.../main/java/org/apache/iotdb/db/service/DataNode.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
index 334bfcdc5cf..6540d21ea93 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -125,6 +125,7 @@ import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -281,8 +282,6 @@ public class DataNode extends ServerCommandLine implements
DataNodeMBean {
nodeIds = Collections.singleton(config.getDataNodeId());
}
- logger.info("Starting to remove DataNode with nodeIds: {}", nodeIds);
-
// Load ConfigNodeList from system.properties file
ConfigNodeInfo.getInstance().loadConfigNodeList();
@@ -290,6 +289,19 @@ public class DataNode extends ServerCommandLine implements
DataNodeMBean {
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID))
{
// Find a datanode location with the given node id.
+ 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