You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "CRZbulabula (via GitHub)" <gi...@apache.org> on 2023/03/16 07:46:25 UTC

[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #9270: [IOTDB-5368] add port check for confignode and datanode

CRZbulabula commented on code in PR #9270:
URL: https://github.com/apache/iotdb/pull/9270#discussion_r1138231345


##########
server/src/main/java/org/apache/iotdb/db/conf/DataNodeStartCheck.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.conf;
+
+import org.apache.iotdb.commons.exception.StartupException;
+import org.apache.iotdb.commons.service.StartupChecks;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/** DataNodeStartCheck checks the parameters in iotdb-datanode.properties when start and restart */
+public class DataNodeStartCheck extends StartupChecks {

Review Comment:
   For consistent with the abstract class:
   ```suggestion
   /** DataNodeStartupCheck checks the parameters in iotdb-datanode.properties when start and restart */
   public class DataNodeStartupCheck extends StartupChecks {
   ```



##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java:
##########
@@ -297,4 +301,47 @@ public void testIllegalNodeRestart()
               Arrays.asList(NodeStatus.Running, NodeStatus.Running));
     }
   }
+
+  @Test
+  public void testIllegalNodeStartUp()
+      throws StartupException, ConfigurationException, IOException, ClientManagerException,
+          InterruptedException, TException {
+    ConfigNodeWrapper portConflictConfigNodeWrapper =
+        EnvFactory.getEnv().generateRandomConfigNodeWrapper();
+    DataNodeWrapper portConflictDataNodeWrapper =
+        EnvFactory.getEnv().generateRandomDataNodeWrapper();
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+      // set ConfigNode port repeat
+      TShowClusterResp showClusterResp = client.showCluster();
+      int beforeStartConfigNodes = showClusterResp.getConfigNodeListSize();
+      portConflictConfigNodeWrapper.setConsensusPort(portConflictConfigNodeWrapper.getPort());
+      portConflictConfigNodeWrapper.changeConfig(
+          (MppBaseConfig) EnvFactory.getEnv().getConfig().getConfigNodeConfig(),
+          (MppCommonConfig) EnvFactory.getEnv().getConfig().getConfigNodeCommonConfig(),
+          null);
+      portConflictConfigNodeWrapper.start();
+      for (int i = 0; i < START_RETRY_NUM; ++i) {
+        showClusterResp = client.showCluster();
+        Thread.sleep(1000);
+      }
+      int afterStartConfigNodes = showClusterResp.getConfigNodeListSize();
+      Assert.assertEquals(beforeStartConfigNodes, afterStartConfigNodes);

Review Comment:
   Either assertEquals of ConfigNodes within each loop or just sleep 10s here.



##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java:
##########
@@ -195,7 +199,7 @@ public void testIllegalNodeRestart()
 
       TConfigNodeRestartReq configNodeRestartReq =
           ConfigNodeTestUtils.generateTConfigNodeRestartReq(
-              ERROR_CLUSTER_NAME, 1, registeredConfigNodeWrapper);
+              ERROR_CLUSTER_NAME, -1, registeredConfigNodeWrapper);

Review Comment:
   Why change this NodeId?
   ```suggestion
                 ERROR_CLUSTER_NAME, 1, registeredConfigNodeWrapper);
   ```



##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java:
##########
@@ -297,4 +301,47 @@ public void testIllegalNodeRestart()
               Arrays.asList(NodeStatus.Running, NodeStatus.Running));
     }
   }
+
+  @Test
+  public void testIllegalNodeStartUp()
+      throws StartupException, ConfigurationException, IOException, ClientManagerException,
+          InterruptedException, TException {
+    ConfigNodeWrapper portConflictConfigNodeWrapper =
+        EnvFactory.getEnv().generateRandomConfigNodeWrapper();
+    DataNodeWrapper portConflictDataNodeWrapper =
+        EnvFactory.getEnv().generateRandomDataNodeWrapper();
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+      // set ConfigNode port repeat
+      TShowClusterResp showClusterResp = client.showCluster();
+      int beforeStartConfigNodes = showClusterResp.getConfigNodeListSize();
+      portConflictConfigNodeWrapper.setConsensusPort(portConflictConfigNodeWrapper.getPort());
+      portConflictConfigNodeWrapper.changeConfig(
+          (MppBaseConfig) EnvFactory.getEnv().getConfig().getConfigNodeConfig(),
+          (MppCommonConfig) EnvFactory.getEnv().getConfig().getConfigNodeCommonConfig(),
+          null);
+      portConflictConfigNodeWrapper.start();
+      for (int i = 0; i < START_RETRY_NUM; ++i) {
+        showClusterResp = client.showCluster();
+        Thread.sleep(1000);
+      }
+      int afterStartConfigNodes = showClusterResp.getConfigNodeListSize();
+      Assert.assertEquals(beforeStartConfigNodes, afterStartConfigNodes);
+      // set datanode port repeat
+      int beforeStartDataNodes = showClusterResp.getDataNodeListSize();
+      portConflictDataNodeWrapper.setMppDataExchangePort(
+          portConflictDataNodeWrapper.getDataRegionConsensusPort());
+      portConflictDataNodeWrapper.changeConfig(
+          (MppBaseConfig) EnvFactory.getEnv().getConfig().getDataNodeConfig(),
+          (MppCommonConfig) EnvFactory.getEnv().getConfig().getDataNodeCommonConfig(),
+          null);
+      portConflictDataNodeWrapper.start();
+      for (int i = 0; i < START_RETRY_NUM; ++i) {
+        showClusterResp = client.showCluster();
+        Thread.sleep(1000);
+      }
+      int afterStartDataNodes = showClusterResp.getDataNodeListSize();
+      Assert.assertEquals(beforeStartDataNodes, afterStartDataNodes);

Review Comment:
   Either assertEquals of DataNodes within each loop or just sleep 10s 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