You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/29 10:27:09 UTC

[GitHub] [iotdb] Beyyes opened a new pull request, #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Beyyes opened a new pull request, #6062:
URL: https://github.com/apache/iotdb/pull/6062

   ## Description
   
   This pr adds the implementation for 'SHOW CLUSTER' command.  It displays the 'NodeId、Role、Status、Host、Ports' informations of current cluster.
   
   See more details in JIRA: https://issues.apache.org/jira/browse/IOTDB-3316
   
   The output result of 'SHOW CLUSTER' is as below .
   ![image](https://user-images.githubusercontent.com/6756545/170863240-6107d324-57d9-421a-a922-820aad0a9924.png)
   
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Beyyes commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
Beyyes commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r884882435


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));

Review Comment:
   remove it



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr merged pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
xingtanzjr merged PR #6062:
URL: https://github.com/apache/iotdb/pull/6062


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
xingtanzjr commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r884857443


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));
+    }
+
+    // build TSBlock
+    TsBlockBuilder builder =
+        new TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
+    int configNodeId = 0;
+    for (TConfigNodeLocation nodeLocation : clusterNodeInfos.getConfigNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(configNodeId++);
+      builder.getColumnBuilder(1).writeBinary(new Binary("ConfigNode"));
+      builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+      builder
+          .getColumnBuilder(3)
+          .writeBinary(new Binary(nodeLocation.getInternalEndPoint().getIp()));
+      builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+      builder.declarePosition();
+    }
+    for (TDataNodeLocation nodeLocation : clusterNodeInfos.getDataNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(nodeLocation.getDataNodeId());
+      builder.getColumnBuilder(1).writeBinary(new Binary("DataNode"));
+      builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+      builder
+          .getColumnBuilder(3)
+          .writeBinary(new Binary(nodeLocation.getInternalEndPoint().getIp()));
+      builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+      builder.declarePosition();

Review Comment:
   Line `92-100` is similar with line `81-89`, suggest to define a function to process it.



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] coveralls commented on pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
coveralls commented on PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#issuecomment-1140700829

   
   [![Coverage Status](https://coveralls.io/builds/49548565/badge)](https://coveralls.io/builds/49548565)
   
   Coverage decreased (-0.1%) to 44.976% when pulling **c9dd5fc8050f2ace1eecfb62ddcf5921ba3aecba on beyyes/feature/show_datanodes** into **c64366776113cccb67374b4b86d65935bc4a07e2 on master**.
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
xingtanzjr commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r884855393


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));
+    }
+
+    // build TSBlock
+    TsBlockBuilder builder =
+        new TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
+    int configNodeId = 0;
+    for (TConfigNodeLocation nodeLocation : clusterNodeInfos.getConfigNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(configNodeId++);
+      builder.getColumnBuilder(1).writeBinary(new Binary("ConfigNode"));

Review Comment:
   Suggest to use constant defined in IoTDBConstant, or use ENUM here



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
xingtanzjr commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r884854976


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;

Review Comment:
   Unused local variable



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] sonarcloud[bot] commented on pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#issuecomment-1141642613

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_incubator-iotdb&pullRequest=6062)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL)
   
   [![13.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '13.2%')](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_coverage&view=list) [13.2% Coverage](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] sonarcloud[bot] commented on pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#issuecomment-1140703403

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_incubator-iotdb&pullRequest=6062)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_incubator-iotdb&pullRequest=6062&resolved=false&types=CODE_SMELL)
   
   [![12.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '12.0%')](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_coverage&view=list) [12.0% Coverage](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_incubator-iotdb&pullRequest=6062&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Beyyes commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
Beyyes commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r885149479


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));
+    }
+
+    // build TSBlock
+    TsBlockBuilder builder =
+        new TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
+    int configNodeId = 0;
+    for (TConfigNodeLocation nodeLocation : clusterNodeInfos.getConfigNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(configNodeId++);
+      builder.getColumnBuilder(1).writeBinary(new Binary("ConfigNode"));

Review Comment:
   used constants defined in IoTDBConstant



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Beyyes commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
Beyyes commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r885149347


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;

Review Comment:
   remove it



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
xingtanzjr commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r884855604


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));

Review Comment:
   `does not`



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] Beyyes commented on a diff in pull request #6062: [IOTDB-3316] Add 'SHOW CLUSTER' implementation for IoTDB cluster mode

Posted by GitBox <gi...@apache.org>.
Beyyes commented on code in PR #6062:
URL: https://github.com/apache/iotdb/pull/6062#discussion_r885149738


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/ShowClusterTask.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.commons.client.IClientManager;
+import org.apache.iotdb.commons.consensus.PartitionRegionId;
+import org.apache.iotdb.confignode.rpc.thrift.TClusterNodeInfos;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.client.ConfigNodeInfo;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
+import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.ShowClusterStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.iotdb.tsfile.utils.Binary;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class ShowClusterTask implements IConfigTask {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(ShowClusterTask.class);
+
+  private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+
+  private ShowClusterStatement showClusterStatement;
+
+  public ShowClusterTask(ShowClusterStatement showClusterStatement) {
+    this.showClusterStatement = showClusterStatement;
+  }
+
+  @Override
+  public ListenableFuture<ConfigTaskResult> execute(
+      IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
+      throws InterruptedException {
+    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    TClusterNodeInfos clusterNodeInfos = new TClusterNodeInfos();
+
+    if (config.isClusterMode()) {
+      try (ConfigNodeClient client = clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+        clusterNodeInfos = client.getAllClusterNodeInfos();
+      } catch (TException | IOException e) {
+        LOGGER.error("Failed to connect to config node.");
+        future.setException(e);
+      }
+    } else {
+      future.setException(new TException("SHOW CLUSTER not support local mode"));
+    }
+
+    // build TSBlock
+    TsBlockBuilder builder =
+        new TsBlockBuilder(HeaderConstant.showClusterHeader.getRespDataTypes());
+    int configNodeId = 0;
+    for (TConfigNodeLocation nodeLocation : clusterNodeInfos.getConfigNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(configNodeId++);
+      builder.getColumnBuilder(1).writeBinary(new Binary("ConfigNode"));
+      builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+      builder
+          .getColumnBuilder(3)
+          .writeBinary(new Binary(nodeLocation.getInternalEndPoint().getIp()));
+      builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+      builder.declarePosition();
+    }
+    for (TDataNodeLocation nodeLocation : clusterNodeInfos.getDataNodeList()) {
+      builder.getTimeColumnBuilder().writeLong(0L);
+      builder.getColumnBuilder(0).writeInt(nodeLocation.getDataNodeId());
+      builder.getColumnBuilder(1).writeBinary(new Binary("DataNode"));
+      builder.getColumnBuilder(2).writeBinary(new Binary("Running"));
+      builder
+          .getColumnBuilder(3)
+          .writeBinary(new Binary(nodeLocation.getInternalEndPoint().getIp()));
+      builder.getColumnBuilder(4).writeInt(nodeLocation.getInternalEndPoint().getPort());
+      builder.declarePosition();

Review Comment:
   Line 92-100 and line 81-89 are extracted in a function



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org