OneSizeFitsQuorum commented on code in PR #12852:
URL: https://github.com/apache/iotdb/pull/12852#discussion_r1669652169
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java:
##########
@@ -2790,6 +2795,119 @@ public SettableFuture<ConfigTaskResult>
showDatabases(ShowDB showDB) {
return future;
}
+ @Override
+ public SettableFuture<ConfigTaskResult> showCluster(ShowCluster showCluster)
{
+ SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ TShowClusterResp showClusterResp = new TShowClusterResp();
+ try (ConfigNodeClient client =
+
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
+ showClusterResp = client.showCluster();
+ } catch (ClientManagerException | TException e) {
+ if (showClusterResp.getConfigNodeList() == null) {
+ future.setException(new TException(MSG_RECONNECTION_FAIL));
+ } else {
+ future.setException(e);
+ }
+ return future;
+ }
+ // build TSBlock
+ if (showCluster.getDetails().orElse(false)) {
+ ShowClusterDetailsTask.buildTSBlock(showClusterResp, future);
+ } else {
+
org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.ShowClusterTask
+ .buildTsBlock(showClusterResp, future);
+ }
+
+ return future;
+ }
+
+ @Override
+ public SettableFuture<ConfigTaskResult> showRegions(ShowRegions showRegions)
{
+ SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ TShowRegionResp showRegionResp = new TShowRegionResp();
+ TShowRegionReq showRegionReq = new TShowRegionReq();
+ showRegionReq.setConsensusGroupType(showRegions.getRegionType());
+ if ((showRegions.getStorageGroups() == null) ||
showRegions.getStorageGroups().isEmpty()) {
+ showRegionReq.setDatabases(null);
+ } else {
+ showRegionReq.setDatabases(
+ showRegions.getStorageGroups().stream()
+ .map(PartialPath::getFullPath)
+ .collect(Collectors.toList()));
+ }
+ try (ConfigNodeClient client =
+
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
+ showRegionResp = client.showRegion(showRegionReq);
+ if (showRegionResp.getStatus().getCode() !=
TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ future.setException(
+ new IoTDBException(
+ showRegionResp.getStatus().message,
showRegionResp.getStatus().code));
+ return future;
+ }
+ } catch (ClientManagerException | TException e) {
+ future.setException(e);
+ }
+
+ // filter the regions by nodeId
+ // TODO: This part currently will remain empty as we're ot implementing
any other filtering
+ // methods right now.
+ if ((showRegions.getNodeIds() != null) &&
!showRegions.getNodeIds().isEmpty()) {
Review Comment:
I mean we could use
`if (showRegions.getNodeIds() != null &&
!showRegions.getNodeIds().isEmpty()) {`
--
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]