Skip to content

Commit bfb0d32

Browse files
authored
[AINode] Optimize the statuscode for remove AINode (#17176)
1 parent 67fda53 commit bfb0d32

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public synchronized DataSet registerAINode(TAINodeRegisterReq req) {
558558
public TSStatus removeAINode() {
559559
// check if the node exists
560560
if (nodeInfo.getRegisteredAINodes().isEmpty()) {
561-
return new TSStatus(TSStatusCode.REMOVE_AI_NODE_ERROR.getStatusCode())
561+
return new TSStatus(TSStatusCode.NO_REGISTERED_AI_NODE_ERROR.getStatusCode())
562562
.setMessage("Remove AINode failed because there is no AINode in the cluster.");
563563
}
564564

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,15 +3550,16 @@ public SettableFuture<ConfigTaskResult> removeAINode(
35503550
LOGGER.info("Starting to remove AINode");
35513551
try (ConfigNodeClient configNodeClient =
35523552
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
3553-
TShowClusterResp showClusterResp = configNodeClient.showCluster();
3554-
if (showClusterResp.getAiNodeListSize() < 1) {
3555-
LOGGER.error("Remove AINode failed because there is no AINode in the cluster.");
3556-
future.setException(
3557-
new IOException("Remove AINode failed because there is no AINode in the cluster."));
3558-
return future;
3559-
}
35603553
TSStatus status = configNodeClient.removeAINode(new TAINodeRemoveReq());
3561-
if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
3554+
if (status.getCode() == TSStatusCode.NO_REGISTERED_AI_NODE_ERROR.getStatusCode()) {
3555+
LOGGER.warn("Remove AINode failed because there is no AINode in the cluster.");
3556+
future.set(
3557+
new ConfigTaskResult(
3558+
new TSStatus(TSStatusCode.NO_REGISTERED_AI_NODE_ERROR.getStatusCode())
3559+
.setMessage(
3560+
"Remove AINode failed because there is no AINode in the cluster.")));
3561+
return future;
3562+
} else if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
35623563
future.setException(new IOException("Remove AINode failed: " + status.getMessage()));
35633564
return future;
35643565
} else {

0 commit comments

Comments
 (0)