You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2020/12/21 15:33:38 UTC

[iotdb] branch change_rpc_port updated: add default test configuration for cluster module

This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch change_rpc_port
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/change_rpc_port by this push:
     new 20aa060  add default test configuration for cluster module
20aa060 is described below

commit 20aa0605637f1d84c3278e60fb1bab4e4aa7c77d
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Mon Dec 21 23:33:11 2020 +0800

    add default test configuration for cluster module
---
 .../java/org/apache/iotdb/cluster/ClusterMain.java | 45 ++++++++++++----------
 .../iotdb/cluster/config/ClusterConstant.java      |  2 +-
 .../iotdb/cluster/config/ClusterDescriptor.java    |  4 ++
 .../resources/node1conf/iotdb-cluster.properties   | 28 ++++++++++++++
 .../resources/node1conf/iotdb-engine.properties    | 23 +++++++++++
 .../resources/node2conf/iotdb-cluster.properties   | 26 +++++++++++++
 .../resources/node2conf/iotdb-engine.properties    | 23 +++++++++++
 .../resources/node3conf/iotdb-cluster.properties   | 34 ++++++++++++++++
 .../resources/node3conf/iotdb-engine.properties    | 23 +++++++++++
 .../apache/iotdb/db/utils/SerializeUtilsTest.java  |  4 +-
 10 files changed, 189 insertions(+), 23 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
index 15b3bd7..2c47841 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java
@@ -76,24 +76,26 @@ public class ClusterMain {
 
   public static void main(String[] args) {
     if (args.length < 1) {
-      logger.error("Usage: <-s|-a|-r> [-{} <internal meta port>] "
-        + "[-{} <internal data port>] "
-        + "[-{} <cluster rpc port>] "
-        + "[-{} <cluster RPC address>]\n"
-        + "[-{} <node1:meta_port:data_port:cluster_rpc_port,"
-        + "node2:meta_port:data_port:cluster_rpc_port,"
-        + "...,noden:meta_port:data_port:cluster_rpc_port,>] "
-        + "[-{} <debug rpc port>]"
-        + "-s: start the node as a seed\n"
-        + "-a: start the node as a new node\n"
-        + "-r: remove the node out of the cluster\n"
-        + "",
-        OPTION_INTERVAL_META_PORT,
-        OPTION_INTERVAL_DATA_PORT,
-        OPTION_CLUSTER_RPC_PORT,
-        OPTION_CLUSTER_RPC_IP,
-        OPTION_SEED_NODES,
-        OPTION_DEBUG_RPC_PORT
+      logger.error("Usage: <-s|-a|-r> "
+              + "[-{} <internal meta port>] "
+              + "[-{} <internal data port>] "
+              + "[-{} <cluster rpc port>] "
+              + "[-{} <cluster RPC address>]\n"
+              + "[-{} <node1:meta_port:data_port:cluster_rpc_port,"
+              + "node2:meta_port:data_port:cluster_rpc_port,"
+              + "...,noden:meta_port:data_port:cluster_rpc_port,>] "
+              + "[-{} <debug rpc port>]"
+              + "-s: start the node as a seed\n"
+              + "-a: start the node as a new node\n"
+              + "-r: remove the node out of the cluster\n"
+              + "or: set CLUSTER_CONF and IOTDB_CONF environment variable",
+          OPTION_INTERVAL_META_PORT,
+          OPTION_INTERVAL_DATA_PORT,
+          OPTION_CLUSTER_RPC_PORT,
+          OPTION_CLUSTER_RPC_IP,
+          OPTION_SEED_NODES,
+          //debug rpc is for starting another rpc port for the singleton IoTDB server.
+          OPTION_DEBUG_RPC_PORT
       );
       return;
     }
@@ -103,13 +105,16 @@ public class ClusterMain {
       replaceDefaultProps(params);
     }
 
+    // init server's configuration first, because the cluster configuration may read settings from
+    // the server's configuration.
+    IoTDBDescriptor.getInstance().getConfig().setSyncEnable(false);
+    IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false);
+
     // params check
     if (!checkConfig()) {
       return;
     }
 
-    IoTDBDescriptor.getInstance().getConfig().setSyncEnable(false);
-    IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false);
     logger.info("Running mode {}", mode);
     if (MODE_START.equals(mode)) {
       try {
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
index 184d0dd..6afe413 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConstant.java
@@ -38,5 +38,5 @@ public class ClusterConstant {
     // constant class
   }
 
-  static final String CLUSTER_CONF = "CLUSTER_CONF";
+  public static final String CLUSTER_CONF = "CLUSTER_CONF";
 }
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterDescriptor.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterDescriptor.java
index b554b85..927a5d2 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterDescriptor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterDescriptor.java
@@ -45,6 +45,10 @@ public class ClusterDescriptor {
   private ClusterConfig config = new ClusterConfig();
 
   private ClusterDescriptor() {
+    // copy needed configurations from the server's config to the cluster.
+    config.setClusterRpcPort(IoTDBDescriptor.getInstance().getConfig().getRpcPort());
+    // then load settings from cluster's file.
+    // so, iotdb-cluster.properties can overwrite iotdb-properties.
     loadProps();
   }
 
diff --git a/cluster/src/test/resources/node1conf/iotdb-cluster.properties b/cluster/src/test/resources/node1conf/iotdb-cluster.properties
new file mode 100644
index 0000000..08ec2fc
--- /dev/null
+++ b/cluster/src/test/resources/node1conf/iotdb-cluster.properties
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+
+internal_ip=127.0.0.1
+internal_meta_port=10010
+internal_data_port=20010
+seed_nodes=127.0.0.1:10010:20010:6667,127.0.0.1:10020:20020:6668,127.0.0.1:10030:20030:6669
+default_replica_num=2
+cluster_name=default
+consistency_level=mid
+
diff --git a/cluster/src/test/resources/node1conf/iotdb-engine.properties b/cluster/src/test/resources/node1conf/iotdb-engine.properties
new file mode 100644
index 0000000..6ca81a1
--- /dev/null
+++ b/cluster/src/test/resources/node1conf/iotdb-engine.properties
@@ -0,0 +1,23 @@
+#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.
+
+rpc_address=127.0.0.1
+rpc_port=6667
+base_dir=target/tmp1
+data_dirs=target/data1
+wal_dir=target/wal1
+index_root_dir=target/index1
diff --git a/cluster/src/test/resources/node2conf/iotdb-cluster.properties b/cluster/src/test/resources/node2conf/iotdb-cluster.properties
new file mode 100644
index 0000000..df38a84
--- /dev/null
+++ b/cluster/src/test/resources/node2conf/iotdb-cluster.properties
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+internal_ip=127.0.0.1
+internal_meta_port=10020
+internal_data_port=20020
+seed_nodes=127.0.0.1:10010:20010:6667,127.0.0.1:10020:20020:6668,127.0.0.1:10030:20030:6669
+default_replica_num=2
+cluster_name=default
+consistency_level=mid
\ No newline at end of file
diff --git a/cluster/src/test/resources/node2conf/iotdb-engine.properties b/cluster/src/test/resources/node2conf/iotdb-engine.properties
new file mode 100644
index 0000000..a4adbbb
--- /dev/null
+++ b/cluster/src/test/resources/node2conf/iotdb-engine.properties
@@ -0,0 +1,23 @@
+#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.
+
+rpc_address=127.0.0.1
+rpc_port=6668
+base_dir=target/tmp2
+data_dirs=target/data2
+wal_dir=target/wal2
+index_root_dir=target/index2
diff --git a/cluster/src/test/resources/node3conf/iotdb-cluster.properties b/cluster/src/test/resources/node3conf/iotdb-cluster.properties
new file mode 100644
index 0000000..c91e063
--- /dev/null
+++ b/cluster/src/test/resources/node3conf/iotdb-cluster.properties
@@ -0,0 +1,34 @@
+#
+# 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.
+#
+
+#-------------------------------------------IMPORTANT---------------------------------------------#
+# Note that the system will automatically create a heartbeat port for each metadata service       #
+# and data service. The default metadata heartbeat port is internal_meta_port + 1,                #
+# The default data heartbeat port is internal_data_port + 1.                                      #
+# So when you configure these two items and seed_nodes, pay attention to reserve a port for       #
+# heartbeat service.                                                                              #
+#-------------------------------------------IMPORTANT---------------------------------------------#
+
+internal_ip=127.0.0.1
+internal_meta_port=10030
+internal_data_port=20030
+seed_nodes=127.0.0.1:10010:20010:6667,127.0.0.1:10020:20020:6668,127.0.0.1:10030:20030:6669
+default_replica_num=2
+cluster_name=default
+consistency_level=mid
\ No newline at end of file
diff --git a/cluster/src/test/resources/node3conf/iotdb-engine.properties b/cluster/src/test/resources/node3conf/iotdb-engine.properties
new file mode 100644
index 0000000..dce2490
--- /dev/null
+++ b/cluster/src/test/resources/node3conf/iotdb-engine.properties
@@ -0,0 +1,23 @@
+#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.
+
+rpc_address=127.0.0.1
+rpc_port=6669
+base_dir=target/tmp3
+data_dirs=target/data3
+wal_dir=target/wal3
+index_root_dir=target/index3
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java
index f38a845..4d90ce7 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java
@@ -88,12 +88,12 @@ public class SerializeUtilsTest {
 
   @Test
   public void serdesNodeTest() {
-    Node node = new Node("127.0.0.1", 6667, 1, 6535, 4678);
+    Node node = new Node("127.0.0.1", 6667, 1, 6535).setClientPort(4678);
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     DataOutputStream outputStream = new DataOutputStream(baos);
     SerializeUtils.serialize(node, outputStream);
     ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
-    Node anotherNode = new Node("127.0.0.1", 6667, 1, 6535, 4678);
+    Node anotherNode = new Node("127.0.0.1", 6667, 1, 6535).setClientPort(4678);
     SerializeUtils.deserialize(anotherNode, buffer);
     Assert.assertEquals(node, anotherNode);
   }