Skip to content

Commit

Permalink
Feature/show ainodes command (apache#13592)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz authored Sep 25, 2024
1 parent ee9b752 commit 0137093
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 113 deletions.
2 changes: 1 addition & 1 deletion iotdb-core/ainode/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "apache-iotdb-ainode"
version = "1.4.0.dev"
version = "2.0.0.dev"
description = "Apache IoTDB AINode"
readme = "README.md"
authors = ["Apache Software Foundation <dev@iotdb.apache.org>"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.PipeStatement;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetProperties;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDB;
Expand Down Expand Up @@ -330,6 +331,7 @@ private IQueryExecution createQueryExecutionForTableModel(
|| statement instanceof ShowRegions
|| statement instanceof ShowDataNodes
|| statement instanceof ShowConfigNodes
|| statement instanceof ShowAINodes
|| statement instanceof Flush
|| statement instanceof SetConfiguration
|| statement instanceof PipeStatement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.CreateTableTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.DescribeTableTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.DropDBTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowAINodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowConfigNodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowDBTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowDataNodesTask;
Expand Down Expand Up @@ -78,6 +79,7 @@
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.QualifiedName;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SetProperties;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDB;
Expand Down Expand Up @@ -253,13 +255,21 @@ protected IConfigTask visitShowRegions(
protected IConfigTask visitShowDataNodes(
final ShowDataNodes showDataNodesStatement, final MPPQueryContext context) {
context.setQueryType(QueryType.READ);
return new ShowDataNodesTask(showDataNodesStatement);
return new ShowDataNodesTask();
}

@Override
protected IConfigTask visitShowConfigNodes(
final ShowConfigNodes showConfigNodesStatement, final MPPQueryContext context) {
context.setQueryType(QueryType.READ);
return new ShowConfigNodesTask(showConfigNodesStatement);
return new ShowConfigNodesTask();
}

@Override
protected IConfigTask visitShowAINodes(
final ShowAINodes showAINodesStatement, final MPPQueryContext context) {
context.setQueryType(QueryType.READ);
return new ShowAINodesTask();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetTimeSlotListTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.MigrateRegionTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.SetTTLTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAINodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterDetailsTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterIdTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterTask;
Expand All @@ -54,7 +55,6 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.UnSetTTLTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.CreateModelTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.DropModelTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.ShowAINodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.ShowModelsTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.template.AlterSchemaTemplateTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.template.CreateSchemaTemplateTask;
Expand Down Expand Up @@ -441,6 +441,12 @@ public IConfigTask visitShowConfigNodes(
return new ShowConfigNodesTask();
}

@Override
public IConfigTask visitShowAINodes(
ShowAINodesStatement showAINodesStatement, MPPQueryContext context) {
return new ShowAINodesTask();
}

@Override
public IConfigTask visitShowPipes(
ShowPipesStatement showPipesStatement, MPPQueryContext context) {
Expand Down Expand Up @@ -612,10 +618,4 @@ public IConfigTask visitShowModels(
ShowModelsStatement showModelsStatement, MPPQueryContext context) {
return new ShowModelsTask(showModelsStatement.getModelName());
}

@Override
public IConfigTask visitShowAINodes(
ShowAINodesStatement showAINodesStatement, MPPQueryContext context) {
return new ShowAINodesTask(showAINodesStatement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetRegionIdTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetSeriesSlotListTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.GetTimeSlotListTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowAINodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterDetailsTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterIdTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowClusterTask;
Expand All @@ -165,7 +166,6 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowTTLTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowTriggersTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.ShowVariablesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.ShowAINodesTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model.ShowModelsTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.DescribeTableTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowDBTask;
Expand All @@ -184,9 +184,7 @@
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.view.AlterLogicalViewNode;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DropDB;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDB;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDataNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowRegions;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Use;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.CountDatabaseStatement;
Expand All @@ -203,12 +201,10 @@
import org.apache.iotdb.db.queryengine.plan.statement.metadata.MigrateRegionStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.SetTTLStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowDataNodesStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowDatabaseStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowRegionStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowTTLStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.CreateModelStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowAINodesStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.AlterPipeStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.CreatePipePluginStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.CreatePipeStatement;
Expand Down Expand Up @@ -1437,8 +1433,7 @@ public SettableFuture<ConfigTaskResult> showRegion(ShowRegionStatement showRegio
}

@Override
public SettableFuture<ConfigTaskResult> showDataNodes(
final ShowDataNodesStatement showDataNodesStatement) {
public SettableFuture<ConfigTaskResult> showDataNodes() {
final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
TShowDataNodesResp showDataNodesResp = new TShowDataNodesResp();
try (final ConfigNodeClient client =
Expand Down Expand Up @@ -1480,6 +1475,24 @@ public SettableFuture<ConfigTaskResult> showConfigNodes() {
return future;
}

@Override
public SettableFuture<ConfigTaskResult> showAINodes() {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
TShowAINodesResp resp = new TShowAINodesResp();
try (ConfigNodeClient client =
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
resp = client.showAINodes();
if (resp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
future.setException(new IoTDBException(resp.getStatus().message, resp.getStatus().code));
return future;
}
} catch (ClientManagerException | TException e) {
future.setException(e);
}
ShowAINodesTask.buildTsBlock(resp, future);
return future;
}

@Override
public SettableFuture<ConfigTaskResult> createSchemaTemplate(
final CreateSchemaTemplateStatement createSchemaTemplateStatement) {
Expand Down Expand Up @@ -2765,24 +2778,6 @@ public SettableFuture<ConfigTaskResult> showModels(String modelName) {
return future;
}

@Override
public SettableFuture<ConfigTaskResult> showAINodes(ShowAINodesStatement showAINodesStatement) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
TShowAINodesResp resp = new TShowAINodesResp();
try (ConfigNodeClient client =
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
resp = client.showAINodes();
if (resp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
future.setException(new IoTDBException(resp.getStatus().message, resp.getStatus().code));
return future;
}
} catch (ClientManagerException | TException e) {
future.setException(e);
}
ShowAINodesTask.buildTsBlock(resp, future);
return future;
}

@Override
public SettableFuture<ConfigTaskResult> setSpaceQuota(
SetSpaceQuotaStatement setSpaceQuotaStatement) {
Expand Down Expand Up @@ -2970,49 +2965,6 @@ public SettableFuture<ConfigTaskResult> showRegions(ShowRegions showRegions) {
return showRegion(treeStatement);
}

@Override
public SettableFuture<ConfigTaskResult> showDataNodes(ShowDataNodes showDataNodes) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
TShowDataNodesResp showDataNodesResp = new TShowDataNodesResp();
try (ConfigNodeClient client =
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
showDataNodesResp = client.showDataNodes();
if (showDataNodesResp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
future.setException(
new IoTDBException(
showDataNodesResp.getStatus().message, showDataNodesResp.getStatus().code));
return future;
}
} catch (ClientManagerException | TException e) {
future.setException(e);
}
// build TSBlock
ShowDataNodesTask.buildTSBlock(showDataNodesResp, future);
return future;
}

@Override
public SettableFuture<ConfigTaskResult> showConfigNodes(ShowConfigNodes showConfigNodes) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
TShowConfigNodesResp showConfigNodesResp = new TShowConfigNodesResp();
try (ConfigNodeClient client =
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
showConfigNodesResp = client.showConfigNodes();
if (showConfigNodesResp.getStatus().getCode()
!= TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
future.setException(
new IoTDBException(
showConfigNodesResp.getStatus().message, showConfigNodesResp.getStatus().code));
return future;
}
} catch (ClientManagerException | TException e) {
future.setException(e);
}
// build TSBlock
ShowConfigNodesTask.buildTSBlock(showConfigNodesResp, future);
return future;
}

@Override
public SettableFuture<ConfigTaskResult> useDatabase(Use useDB, IClientSession clientSession) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.view.AlterLogicalViewNode;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DropDB;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDB;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowDataNodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowRegions;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Use;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.CountDatabaseStatement;
Expand All @@ -54,12 +52,10 @@
import org.apache.iotdb.db.queryengine.plan.statement.metadata.MigrateRegionStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.SetTTLStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowClusterStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowDataNodesStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowDatabaseStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowRegionStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowTTLStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.CreateModelStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowAINodesStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.AlterPipeStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.CreatePipePluginStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.pipe.CreatePipeStatement;
Expand Down Expand Up @@ -160,10 +156,12 @@ public interface IConfigTaskExecutor {

SettableFuture<ConfigTaskResult> showRegion(ShowRegionStatement showRegionStatement);

SettableFuture<ConfigTaskResult> showDataNodes(ShowDataNodesStatement showDataNodesStatement);
SettableFuture<ConfigTaskResult> showDataNodes();

SettableFuture<ConfigTaskResult> showConfigNodes();

SettableFuture<ConfigTaskResult> showAINodes();

SettableFuture<ConfigTaskResult> createSchemaTemplate(
CreateSchemaTemplateStatement createSchemaTemplateStatement);

Expand Down Expand Up @@ -267,8 +265,6 @@ SettableFuture<ConfigTaskResult> createModel(

SettableFuture<ConfigTaskResult> showModels(String modelName);

SettableFuture<ConfigTaskResult> showAINodes(ShowAINodesStatement showAINodesStatement);

TPipeTransferResp handleTransferConfigPlan(String clientId, TPipeTransferReq req);

void handlePipeConfigClientExit(String clientId);
Expand All @@ -281,10 +277,6 @@ SettableFuture<ConfigTaskResult> createModel(

SettableFuture<ConfigTaskResult> showRegions(ShowRegions showRegions);

SettableFuture<ConfigTaskResult> showDataNodes(ShowDataNodes showDataNodes);

SettableFuture<ConfigTaskResult> showConfigNodes(ShowConfigNodes showConfigNodes);

SettableFuture<ConfigTaskResult> useDatabase(final Use useDB, final IClientSession clientSession);

SettableFuture<ConfigTaskResult> dropDatabase(final DropDB dropDB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iotdb.db.queryengine.plan.execution.config.metadata.model;
package org.apache.iotdb.db.queryengine.plan.execution.config.metadata;

import org.apache.iotdb.confignode.rpc.thrift.TAINodeInfo;
import org.apache.iotdb.confignode.rpc.thrift.TShowAINodesResp;
Expand All @@ -28,7 +28,6 @@
import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult;
import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowAINodesStatement;
import org.apache.iotdb.rpc.TSStatusCode;

import com.google.common.util.concurrent.ListenableFuture;
Expand All @@ -42,16 +41,14 @@

public class ShowAINodesTask implements IConfigTask {

private final ShowAINodesStatement showAINodesStatement;

public ShowAINodesTask(ShowAINodesStatement showAINodesStatement) {
this.showAINodesStatement = showAINodesStatement;
public ShowAINodesTask() {
// do nothing
}

@Override
public ListenableFuture<ConfigTaskResult> execute(IConfigTaskExecutor configTaskExecutor)
throws InterruptedException {
return configTaskExecutor.showAINodes(showAINodesStatement);
return configTaskExecutor.showAINodes();
}

public static void buildTsBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ShowDataNodesTask(ShowDataNodesStatement showDataNodesStatement) {
@Override
public ListenableFuture<ConfigTaskResult> execute(IConfigTaskExecutor configTaskExecutor)
throws InterruptedException {
return configTaskExecutor.showDataNodes(showDataNodesStatement);
return configTaskExecutor.showDataNodes();
}

public static void buildTSBlock(
Expand Down
Loading

0 comments on commit 0137093

Please sign in to comment.