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

dope pushed a commit to branch cluster
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/cluster by this push:
     new 48c8eb7  add deploy script
     new 08380eb  Merge branch 'cluster' of github.com:apache/incubator-iotdb 
into cluster
48c8eb7 is described below

commit 48c8eb7f41c1280dc4cd394cef50f4f1737e9817
Author: MyXOF <[email protected]>
AuthorDate: Tue Apr 9 22:19:50 2019 +0800

    add deploy script
---
 cluster/script/deploy.sh                           |  80 +++++++
 cluster/script/stop.sh                             |  36 ++++
 .../cluster/config/ClusterDescriptorTest.java      |  11 +-
 ...etchIT.java => IoTDBMetadataFetchAbstract.java} | 232 +++++++++------------
 .../integration/IoTDBMetadataFetchLocallyIT.java   |  91 ++++++++
 .../integration/IoTDBMetadataFetchRemoteIT.java    | 117 +++++++++++
 .../iotdb/cluster/qp/ClusterQPExecutorTest.java    |   5 +-
 .../cluster/qp/executor/NonQueryExecutorTest.java  |   2 +-
 .../cluster/utils/ClusterConfigureGenerator.java   |  95 +++++++++
 .../iotdb/cluster/utils/EnvironmentUtils.java      | 158 --------------
 .../java/org/apache/iotdb/cluster/utils/Utils.java |  34 +++
 .../iotdb/cluster/utils/hash/RouterTest.java       |   2 +-
 12 files changed, 556 insertions(+), 307 deletions(-)

diff --git a/cluster/script/deploy.sh b/cluster/script/deploy.sh
new file mode 100755
index 0000000..bbd1028
--- /dev/null
+++ b/cluster/script/deploy.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# 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 file locally ==========
+## cd ../../
+#cd iotdb/iotdb
+#rm -rf data/
+#rm -rf lib/
+#rm -rf lib_cluster/
+#rm -rf logs/
+#cd ../..
+#git pull
+#mvn clean package -pl cluster -am -Dmaven.test.skip=true
+#cd iotdb
+#rm cluster.zip
+#zip -r cluster.zip iotdb/
+#cd ..
+
+## ========== package file locally end ==========
+
+
+## ========== transfer to node ==========
+
+#alliplist=('192.168.130.12' '192.168.130.14' '192.168.130.16' 
'192.168.130.18' '192.168.130.19')
+#for ip in ${alliplist[@]}
+#do
+#  ssh fit@$ip "rm /home/fit/xuyi/cluster.zip"
+#  ssh fit@$ip "rm -rf /home/fit/xuyi/iotdb"
+#  scp iotdb/cluster.zip fit@$ip:/home/fit/xuyi
+#  ssh fit@$ip "unzip -o -d /home/fit/xuyi /home/fit/xuyi/cluster.zip "
+#done
+## ========== transfer to node end ==========
+
+
+nodes=$1
+if [ $nodes == "3" ]
+then
+  iplist=('192.168.130.14' '192.168.130.16' '192.168.130.18')
+else
+  iplist=('192.168.130.12' '192.168.130.14' '192.168.130.16' '192.168.130.18' 
'192.168.130.19')
+fi
+
+replication=$2
+
+
+for ip in ${iplist[@]}
+do
+  idx="$(cut -d'.' -f4 <<<"$ip")"
+  cat $3/src/test/resources/conf/$nodes-$replication-$idx.properties
+#  scp $3/src/test/resources/conf/$nodes-$replication-$idx.properties 
fit@$ip:/home/fit/xuyi/iotdb/conf/iotdb-cluster.properties
+done
+
+for ip in ${iplist[@]}
+do
+  ssh fit@$ip "chmod a+x /home/fit/xuyi/iotdb/bin/stop-cluster.sh"
+  ssh fit@$ip "sh /home/fit/xuyi/iotdb/bin/stop-cluster.sh"
+  ssh fit@$ip "rm -rf /home/fit/xuyi/iotdb/data"
+  ssh fit@$ip "rm -rf /home/fit/xuyi/iotdb/logs"
+  ssh fit@$ip "chmod a+x /home/fit/xuyi/iotdb/bin/start-cluster.sh"
+  ssh fit@$ip "nohup /home/fit/xuyi/iotdb/bin/start-cluster.sh > output.log 
2>&1 &"
+done
+
diff --git a/cluster/script/stop.sh b/cluster/script/stop.sh
new file mode 100755
index 0000000..b4cdf41
--- /dev/null
+++ b/cluster/script/stop.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# 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.
+#
+
+nodes=$1
+if [ $nodes == "3" ]
+then
+  iplist=('192.168.130.14' '192.168.130.16' '192.168.130.18')
+else
+  iplist=('192.168.130.12' '192.168.130.14' '192.168.130.16' '192.168.130.18' 
'192.168.130.19')
+fi
+
+for ip in ${iplist[@]}
+do
+  ssh fit@$ip "chmod a+x /home/fit/xuyi/iotdb/bin/stop-cluster.sh"
+  ssh fit@$ip "sh /home/fit/xuyi/iotdb/bin/stop-cluster.sh"
+  ssh fit@$ip "rm -rf /home/fit/xuyi/iotdb/data"
+  ssh fit@$ip "rm -rf /home/fit/xuyi/iotdb/logs"
+done
+
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/config/ClusterDescriptorTest.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/config/ClusterDescriptorTest.java
index b176654..3572d25 100644
--- 
a/cluster/src/test/java/org/apache/iotdb/cluster/config/ClusterDescriptorTest.java
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/config/ClusterDescriptorTest.java
@@ -28,9 +28,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import org.apache.commons.io.FileUtils;
-import org.apache.iotdb.cluster.utils.EnvironmentUtils;
 import org.apache.iotdb.db.conf.IoTDBConstant;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -47,6 +45,7 @@ public class ClusterDescriptorTest {
   private String testRaftLogPathNew = "/tmp/log";
   private String testRaftSnapshotPathNew = "/tmp/snapshot";
   private String testRaftMetadataPathNew = "/tmp/metadata";
+  private String testElectionTimeOutNew = "1234";
   private String testMaxCatchUpLogNumNew = "50000";
   private String testDelaySnapshotNew = "true";
   private String testDelayHoursNew = "1111";
@@ -65,6 +64,7 @@ public class ClusterDescriptorTest {
   private String testRaftLogPathOld;
   private String testRaftSnapshotPathOld;
   private String testRaftMetadataPathOld;
+  private int testElectionTimeOutOld;
   private int testMaxCatchUpLogNumOld;
   private boolean testDelaySnapshotOld;
   private int testDelayHoursOld;
@@ -86,6 +86,7 @@ public class ClusterDescriptorTest {
       put("raft_log_path", testRaftLogPathNew);
       put("raft_snapshot_path", testRaftSnapshotPathNew);
       put("raft_metadata_path", testRaftMetadataPathNew);
+      put("election_timeout_ms", testElectionTimeOutNew);
       put("max_catch_up_log_num", testMaxCatchUpLogNumNew);
       put("delay_snapshot", testDelaySnapshotNew);
       put("delay_hours", testDelayHoursNew);
@@ -101,7 +102,6 @@ public class ClusterDescriptorTest {
 
   @Before
   public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
     deleteConfigFile();
     createTestConfigFile();
     storeOldConfig();
@@ -111,7 +111,6 @@ public class ClusterDescriptorTest {
   public void tearDown() throws Exception {
     restoreOldConfig();
     deleteConfigFile();
-    EnvironmentUtils.cleanEnv();
   }
 
   @Test
@@ -131,6 +130,7 @@ public class ClusterDescriptorTest {
     assertEquals(testRaftLogPathNew, config.getRaftLogPath() + "");
     assertEquals(testRaftSnapshotPathNew, config.getRaftSnapshotPath() + "");
     assertEquals(testRaftMetadataPathNew, config.getRaftMetadataPath() + "");
+    assertEquals(testElectionTimeOutNew, config.getElectionTimeoutMs()+"");
     assertEquals(testMaxCatchUpLogNumNew, config.getMaxCatchUpLogNum() + "");
     assertEquals(testDelaySnapshotNew, config.isDelaySnapshot() + "");
     assertEquals(testDelayHoursNew, config.getDelayHours() + "");
@@ -180,6 +180,7 @@ public class ClusterDescriptorTest {
     testRaftLogPathOld = config.getRaftLogPath();
     testRaftSnapshotPathOld = config.getRaftSnapshotPath();
     testRaftMetadataPathOld = config.getRaftMetadataPath();
+    testElectionTimeOutOld = config.getElectionTimeoutMs();
     testMaxCatchUpLogNumOld = config.getMaxCatchUpLogNum();
     testDelaySnapshotOld = config.isDelaySnapshot();
     testDelayHoursOld = config.getDelayHours();
@@ -201,6 +202,7 @@ public class ClusterDescriptorTest {
     config.setRaftLogPath(testRaftLogPathOld);
     config.setRaftMetadataPath(testRaftMetadataPathOld);
     config.setRaftSnapshotPath(testRaftSnapshotPathOld);
+    config.setElectionTimeoutMs(testElectionTimeOutOld);
     config.setMaxCatchUpLogNum(testMaxCatchUpLogNumOld);
     config.setDelayHours(testDelayHoursOld);
     config.setDelaySnapshot(testDelaySnapshotOld);
@@ -212,5 +214,4 @@ public class ClusterDescriptorTest {
     config.setReadMetadataConsistencyLevel(testMetadataConsistencyOld);
     config.setReadDataConsistencyLevel(testDataConsistencyOld);
   }
-
 }
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchAbstract.java
similarity index 64%
rename from 
cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
rename to 
cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchAbstract.java
index 60b5b03..d0f371f 100644
--- 
a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchIT.java
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchAbstract.java
@@ -27,46 +27,16 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
-import org.apache.iotdb.cluster.config.ClusterConfig;
-import org.apache.iotdb.cluster.config.ClusterDescriptor;
-import org.apache.iotdb.cluster.entity.Server;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.jdbc.Config;
 import org.apache.iotdb.jdbc.Constant;
-import org.junit.After;
 import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
-public class IoTDBMetadataFetchIT {
-
-  private Server server;
-  private ClusterConfig config = ClusterDescriptor.getInstance().getConfig();
-
-  @Before
-  public void setUp() throws Exception {
-    EnvironmentUtils.cleanEnv();
-    EnvironmentUtils.closeStatMonitor();
-    EnvironmentUtils.closeMemControl();
-    config.createAllPath();
-    server = Server.getInstance();
-    server.start();
-    EnvironmentUtils.envSetUp();
-    Class.forName(Config.JDBC_DRIVER_NAME);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    server.stop();
-    EnvironmentUtils.cleanEnv();
-  }
-
-  @Test
-  public void test() throws SQLException {
+public abstract class IoTDBMetadataFetchAbstract{
+  protected void test(String url, boolean isBatch) throws SQLException{
     Connection connection = null;
     try {
-      connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + 
"127.0.0.1:6667/", "root", "root");
-      insertSQL(connection, false);
+      connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + url, 
"root", "root");
+      insertSQL(connection, isBatch);
       testShowStorageGroup(connection);
       testDatabaseMetadata(connection);
       testShowTimeseries(connection);
@@ -76,43 +46,29 @@ public class IoTDBMetadataFetchIT {
     }
   }
 
-  @Test
-  public void testBatch() throws SQLException {
-    Connection connection = null;
-    try {
-      connection = DriverManager.getConnection(Config.IOTDB_URL_PREFIX + 
"127.0.0.1:6667/", "root", "root");
-      insertSQL(connection, true);
-      testShowStorageGroup(connection);
-      testDatabaseMetadata(connection);
-      testShowTimeseries(connection);
-      testShowTimeseriesPath(connection);
-    } finally {
-      connection.close();
-    }
-  }
 
-  private void insertSQL(Connection connection, boolean isBatch) throws 
SQLException {
+  protected void insertSQL(Connection connection, boolean isBatch) throws 
SQLException {
     Statement statement = connection.createStatement();
     String[] insertSqls = new String[]{
-      "SET STORAGE GROUP TO root.ln.wf01",
-      "SET STORAGE GROUP TO root.ln.wf02",
-      "SET STORAGE GROUP TO root.ln.wf03",
-      "SET STORAGE GROUP TO root.ln.wf04",
-      "SET STORAGE GROUP TO root.ln.wf05",
-      "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE = BOOLEAN, 
ENCODING = PLAIN",
-      "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE = FLOAT, 
ENCODING = RLE, compressor = SNAPPY, MAX_POINT_NUMBER = 3",
-      "CREATE TIMESERIES root.ln.wf01.wt02.humidity WITH DATATYPE = DOUBLE, 
ENCODING = RLE",
+        "SET STORAGE GROUP TO root.ln.wf01",
+        "SET STORAGE GROUP TO root.ln.wf02",
+        "SET STORAGE GROUP TO root.ln.wf03",
+        "SET STORAGE GROUP TO root.ln.wf04",
+        "SET STORAGE GROUP TO root.ln.wf05",
+        "CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE = BOOLEAN, 
ENCODING = PLAIN",
+        "CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE = 
FLOAT, ENCODING = RLE, compressor = SNAPPY, MAX_POINT_NUMBER = 3",
+        "CREATE TIMESERIES root.ln.wf01.wt02.humidity WITH DATATYPE = DOUBLE, 
ENCODING = RLE",
 
-      "CREATE TIMESERIES root.ln.wf02.wt03.status WITH DATATYPE = INT32, 
ENCODING = PLAIN",
-      "CREATE TIMESERIES root.ln.wf02.wt04.temperature WITH DATATYPE = FLOAT, 
ENCODING = RLE",
+        "CREATE TIMESERIES root.ln.wf02.wt03.status WITH DATATYPE = INT32, 
ENCODING = PLAIN",
+        "CREATE TIMESERIES root.ln.wf02.wt04.temperature WITH DATATYPE = 
FLOAT, ENCODING = RLE",
 
-      "CREATE TIMESERIES root.ln.wf03.wt02.status WITH DATATYPE = INT64, 
ENCODING = PLAIN",
-      "CREATE TIMESERIES root.ln.wf03.wt03.temperature WITH DATATYPE = FLOAT, 
ENCODING = TS_2DIFF, MAX_POINT_NUMBER = 5",
+        "CREATE TIMESERIES root.ln.wf03.wt02.status WITH DATATYPE = INT64, 
ENCODING = PLAIN",
+        "CREATE TIMESERIES root.ln.wf03.wt03.temperature WITH DATATYPE = 
FLOAT, ENCODING = TS_2DIFF, MAX_POINT_NUMBER = 5",
 
-      "CREATE TIMESERIES root.ln.wf04.wt04.status WITH DATATYPE = TEXT, 
ENCODING = PLAIN",
-      "CREATE TIMESERIES root.ln.wf04.wt05.temperature WITH DATATYPE = FLOAT, 
ENCODING = GORILLA",
+        "CREATE TIMESERIES root.ln.wf04.wt04.status WITH DATATYPE = TEXT, 
ENCODING = PLAIN",
+        "CREATE TIMESERIES root.ln.wf04.wt05.temperature WITH DATATYPE = 
FLOAT, ENCODING = GORILLA",
 
-      "CREATE TIMESERIES root.ln.wf05.wt01.status WITH DATATYPE = DOUBLE, 
ENCODING = PLAIN",
+        "CREATE TIMESERIES root.ln.wf05.wt01.status WITH DATATYPE = DOUBLE, 
ENCODING = PLAIN",
     };
     if (isBatch) {
       for (String sql : insertSqls) {
@@ -128,7 +84,7 @@ public class IoTDBMetadataFetchIT {
     statement.close();
   }
 
-  private void testShowStorageGroup(Connection connection) throws SQLException 
{
+  protected void testShowStorageGroup(Connection connection) throws 
SQLException {
     Statement statement = connection.createStatement();
     String[] sqls = new String[]{
         "show storage group",
@@ -136,15 +92,15 @@ public class IoTDBMetadataFetchIT {
     };
     String[] standards = new String[]{
         "root.ln.wf04,\n"
-          + "root.ln.wf03,\n"
-          + "root.ln.wf02,\n"
-          + "root.ln.wf01,\n"
-          + "root.ln.wf05,\n",
+            + "root.ln.wf03,\n"
+            + "root.ln.wf02,\n"
+            + "root.ln.wf01,\n"
+            + "root.ln.wf05,\n",
     };
     checkCorrectness(sqls, standards, statement);
   }
 
-  private void testShowTimeseriesPath(Connection connection) throws 
SQLException{
+  protected void testShowTimeseriesPath(Connection connection) throws 
SQLException{
     Statement statement = connection.createStatement();
     String[] sqls = new String[]{
         "show timeseries root.ln.wf01.wt01.status", // full seriesPath
@@ -160,29 +116,29 @@ public class IoTDBMetadataFetchIT {
     String[] standards = new String[]{
         "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n",
         "root.ln.wf04.wt04.status,root.ln.wf04,TEXT,PLAIN,\n"
-          +"root.ln.wf04.wt05.temperature,root.ln.wf04,FLOAT,GORILLA,\n"
-          +"root.ln.wf03.wt02.status,root.ln.wf03,INT64,PLAIN,\n"
-          +"root.ln.wf03.wt03.temperature,root.ln.wf03,FLOAT,TS_2DIFF,\n"
-          +"root.ln.wf02.wt03.status,root.ln.wf02,INT32,PLAIN,\n"
-          +"root.ln.wf02.wt04.temperature,root.ln.wf02,FLOAT,RLE,\n"
-          +"root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-          +"root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
-          +"root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n"
-          +"root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
+            +"root.ln.wf04.wt05.temperature,root.ln.wf04,FLOAT,GORILLA,\n"
+            +"root.ln.wf03.wt02.status,root.ln.wf03,INT64,PLAIN,\n"
+            +"root.ln.wf03.wt03.temperature,root.ln.wf03,FLOAT,TS_2DIFF,\n"
+            +"root.ln.wf02.wt03.status,root.ln.wf02,INT32,PLAIN,\n"
+            +"root.ln.wf02.wt04.temperature,root.ln.wf02,FLOAT,RLE,\n"
+            +"root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
+            +"root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
+            +"root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n"
+            +"root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
         "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-          +"root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n",
+            +"root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n",
         "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-          + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
+            + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
         "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-          + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
-          + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
+            + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
+            + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n",
         "",
         ""
     };
     checkCorrectness(sqls, standards, statement);
   }
 
-  private void testShowTimeseries(Connection connection) throws SQLException {
+  protected void testShowTimeseries(Connection connection) throws SQLException 
{
     Statement statement = connection.createStatement();
     try {
       statement.execute("show timeseries");
@@ -195,7 +151,7 @@ public class IoTDBMetadataFetchIT {
     }
   }
 
-  private void testDatabaseMetadata(Connection connection) throws SQLException{
+  protected void testDatabaseMetadata(Connection connection) throws 
SQLException{
     DatabaseMetaData databaseMetaData = connection.getMetaData();
     showTimeseriesInJson(databaseMetaData);
     showStorageGroup(databaseMetaData);
@@ -204,7 +160,7 @@ public class IoTDBMetadataFetchIT {
     showTimeseriesInfo(databaseMetaData);
   }
 
-  private void checkCorrectness(String[] sqls, String[] standards, Statement 
statement) throws SQLException{
+  protected void checkCorrectness(String[] sqls, String[] standards, Statement 
statement) throws SQLException {
     for (int i = 0; i < sqls.length; i++) {
       String sql = sqls[i];
       String standard = standards[i];
@@ -231,19 +187,19 @@ public class IoTDBMetadataFetchIT {
     }
   }
 
-  private void showTimeseriesInfo(DatabaseMetaData databaseMetaData) throws 
SQLException {
+  protected void showTimeseriesInfo(DatabaseMetaData databaseMetaData) throws 
SQLException {
     String standard =
         "Timeseries,Storage Group,DataType,Encoding,\n"
-        + "root.ln.wf04.wt04.status,root.ln.wf04,TEXT,PLAIN,\n"
-        + "root.ln.wf04.wt05.temperature,root.ln.wf04,FLOAT,GORILLA,\n"
-        + "root.ln.wf03.wt02.status,root.ln.wf03,INT64,PLAIN,\n"
-        + "root.ln.wf03.wt03.temperature,root.ln.wf03,FLOAT,TS_2DIFF,\n"
-        + "root.ln.wf02.wt03.status,root.ln.wf02,INT32,PLAIN,\n"
-        + "root.ln.wf02.wt04.temperature,root.ln.wf02,FLOAT,RLE,\n"
-        + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-        + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
-        + "root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n"
-        + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n";
+            + "root.ln.wf04.wt04.status,root.ln.wf04,TEXT,PLAIN,\n"
+            + "root.ln.wf04.wt05.temperature,root.ln.wf04,FLOAT,GORILLA,\n"
+            + "root.ln.wf03.wt02.status,root.ln.wf03,INT64,PLAIN,\n"
+            + "root.ln.wf03.wt03.temperature,root.ln.wf03,FLOAT,TS_2DIFF,\n"
+            + "root.ln.wf02.wt03.status,root.ln.wf02,INT32,PLAIN,\n"
+            + "root.ln.wf02.wt04.temperature,root.ln.wf02,FLOAT,RLE,\n"
+            + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
+            + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
+            + "root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n"
+            + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n";
     ResultSet resultSet = 
databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, "root", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
@@ -254,31 +210,31 @@ public class IoTDBMetadataFetchIT {
 
     standard =
         "Timeseries,Storage Group,DataType,Encoding,\n"
-      + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-      + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
-      + "root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n";
+            + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
+            + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
+            + "root.ln.wf01.wt02.humidity,root.ln.wf01,DOUBLE,RLE,\n";
     resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, 
"root.ln.wf01", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
 
     standard =
         "Timeseries,Storage Group,DataType,Encoding,\n"
-      + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
-      + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
-      + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n";
+            + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n"
+            + "root.ln.wf01.wt01.temperature,root.ln.wf01,FLOAT,RLE,\n"
+            + "root.ln.wf05.wt01.status,root.ln.wf05,DOUBLE,PLAIN,\n";
     resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, 
"root.ln.*.wt01", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
 
     standard =
         "Timeseries,Storage Group,DataType,Encoding,\n"
-      + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n";
+            + "root.ln.wf01.wt01.status,root.ln.wf01,BOOLEAN,PLAIN,\n";
     resultSet = databaseMetaData.getColumns(Constant.CATALOG_TIMESERIES, 
"root.ln.wf01.wt01.status", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
   }
 
-  private void showTimeseriesInJson(DatabaseMetaData databaseMetaData) {
+  protected void showTimeseriesInJson(DatabaseMetaData databaseMetaData) {
     String metadataInJson = databaseMetaData.toString();
     String standard =
         "===  Timeseries Tree  ===\n"
@@ -391,30 +347,30 @@ public class IoTDBMetadataFetchIT {
     Assert.assertEquals(standard, metadataInJson);
   }
 
-  private void showStorageGroup(DatabaseMetaData databaseMetaData) throws 
SQLException {
+  protected void showStorageGroup(DatabaseMetaData databaseMetaData) throws 
SQLException {
     String standard =
         "Storage Group,\n"
-      + "root.ln.wf04,\n"
-      + "root.ln.wf03,\n"
-      + "root.ln.wf02,\n"
-      + "root.ln.wf01,\n"
-      + "root.ln.wf05,\n";
+            + "root.ln.wf04,\n"
+            + "root.ln.wf03,\n"
+            + "root.ln.wf02,\n"
+            + "root.ln.wf01,\n"
+            + "root.ln.wf05,\n";
     ResultSet resultSet = 
databaseMetaData.getColumns(Constant.CATALOG_STORAGE_GROUP, null, null, null);
     checkCorrectness(resultSet, standard);
   }
 
-  private void showDeltaObject(DatabaseMetaData databaseMetaData) throws 
SQLException {
+  protected void showDeltaObject(DatabaseMetaData databaseMetaData) throws 
SQLException {
     String standard =
         "Column,\n"
-      + "root.ln.wf02.wt04,\n"
-      + "root.ln.wf02.wt03,\n"
-      + "root.ln.wf04.wt05,\n"
-      + "root.ln.wf04.wt04,\n"
-      + "root.ln.wf01.wt01,\n"
-      + "root.ln.wf05.wt01,\n"
-      + "root.ln.wf01.wt02,\n"
-      + "root.ln.wf03.wt03,\n"
-      + "root.ln.wf03.wt02,\n";
+            + "root.ln.wf02.wt04,\n"
+            + "root.ln.wf02.wt03,\n"
+            + "root.ln.wf04.wt05,\n"
+            + "root.ln.wf04.wt04,\n"
+            + "root.ln.wf01.wt01,\n"
+            + "root.ln.wf05.wt01,\n"
+            + "root.ln.wf01.wt02,\n"
+            + "root.ln.wf03.wt03,\n"
+            + "root.ln.wf03.wt02,\n";
     ResultSet resultSet = databaseMetaData.getColumns(Constant.CATALOG_DEVICE, 
"ln", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
@@ -425,42 +381,42 @@ public class IoTDBMetadataFetchIT {
     resultSet.close();
   }
 
-  private void showAllColumns(DatabaseMetaData databaseMetaData) throws 
SQLException {
+  protected void showAllColumns(DatabaseMetaData databaseMetaData) throws 
SQLException {
     String standard =
         "Column,\n"
-      + "root.ln.wf04.wt04.status,\n"
-      + "root.ln.wf04.wt05.temperature,\n"
-      + "root.ln.wf03.wt02.status,\n"
-      + "root.ln.wf03.wt03.temperature,\n"
-      + "root.ln.wf02.wt03.status,\n"
-      + "root.ln.wf02.wt04.temperature,\n"
-      + "root.ln.wf01.wt01.status,\n"
-      + "root.ln.wf01.wt01.temperature,\n"
-      + "root.ln.wf01.wt02.humidity,\n"
-      + "root.ln.wf05.wt01.status,\n";
+            + "root.ln.wf04.wt04.status,\n"
+            + "root.ln.wf04.wt05.temperature,\n"
+            + "root.ln.wf03.wt02.status,\n"
+            + "root.ln.wf03.wt03.temperature,\n"
+            + "root.ln.wf02.wt03.status,\n"
+            + "root.ln.wf02.wt04.temperature,\n"
+            + "root.ln.wf01.wt01.status,\n"
+            + "root.ln.wf01.wt01.temperature,\n"
+            + "root.ln.wf01.wt02.humidity,\n"
+            + "root.ln.wf05.wt01.status,\n";
     ResultSet resultSet = databaseMetaData.getColumns(Constant.CATALOG_COLUMN, 
"root", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
 
     standard =
         "Column,\n"
-      + "root.ln.wf01.wt01.status,\n"
-      + "root.ln.wf01.wt01.temperature,\n"
-      + "root.ln.wf01.wt02.humidity,\n";
+            + "root.ln.wf01.wt01.status,\n"
+            + "root.ln.wf01.wt01.temperature,\n"
+            + "root.ln.wf01.wt02.humidity,\n";
     resultSet = databaseMetaData.getColumns(Constant.CATALOG_COLUMN, 
"root.ln.wf01", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
 
     standard =
         "Column,\n"
-      + "root.ln.wf03.wt02.status,\n"
-      + "root.ln.wf01.wt02.humidity,\n";
+            + "root.ln.wf03.wt02.status,\n"
+            + "root.ln.wf01.wt02.humidity,\n";
     resultSet = databaseMetaData.getColumns(Constant.CATALOG_COLUMN, 
"root.ln.*.wt02", null, null);
     checkCorrectness(resultSet, standard);
     resultSet.close();
   }
 
-  private void checkCorrectness(ResultSet resultSet, String standard) throws 
SQLException{
+  protected void checkCorrectness(ResultSet resultSet, String standard) throws 
SQLException{
     ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
     int colCount = resultSetMetaData.getColumnCount();
     StringBuilder resultStr = new StringBuilder();
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchLocallyIT.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchLocallyIT.java
new file mode 100644
index 0000000..b36771a
--- /dev/null
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchLocallyIT.java
@@ -0,0 +1,91 @@
+/**
+ * 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.cluster.integration;
+
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.iotdb.cluster.config.ClusterConfig;
+import org.apache.iotdb.cluster.config.ClusterDescriptor;
+import org.apache.iotdb.cluster.entity.Server;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IoTDBMetadataFetchLocallyIT extends IoTDBMetadataFetchAbstract{
+
+  private Server server;
+  private ClusterConfig config = ClusterDescriptor.getInstance().getConfig();
+
+  private final String URL = "127.0.0.1:6667/";
+  private Map<String, String> testConfigMap = new HashMap<String, String>() {
+    private static final long serialVersionUID = 7832408957178621132L;
+    {
+
+      put("port", "8888");
+      put("election_timeout_ms", "1000");
+      put("max_catch_up_log_num", "100000");
+      put("delay_snapshot", "false");
+      put("delay_hours", "2");
+      put("task_redo_count", "3");
+      put("task_timeout_ms", "1000");
+      put("num_of_virtual_nodes", "2");
+      put("max_num_of_inner_rpc_client", "50");
+      put("max_queue_num_of_inner_rpc_client", "50");
+      put("read_metadata_consistency_level", "1");
+      put("read_data_consistency_level", "1");
+    }
+  };
+  @Before
+  public void setUp() throws Exception {
+    EnvironmentUtils.cleanEnv();
+    EnvironmentUtils.closeStatMonitor();
+    EnvironmentUtils.closeMemControl();
+    config.createAllPath();
+    server = Server.getInstance();
+    server.start();
+    EnvironmentUtils.envSetUp();
+    Class.forName(Config.JDBC_DRIVER_NAME);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    server.stop();
+    EnvironmentUtils.cleanEnv();
+  }
+
+  @Test
+  public void testLocal() throws SQLException {
+    test(URL, false);
+  }
+
+  @Test
+  public void testBatchLocal() throws SQLException {
+    test(URL, true);
+  }
+
+
+
+
+
+
+}
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchRemoteIT.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchRemoteIT.java
new file mode 100644
index 0000000..681402b
--- /dev/null
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/integration/IoTDBMetadataFetchRemoteIT.java
@@ -0,0 +1,117 @@
+/**
+ * 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.cluster.integration;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.sql.SQLException;
+import org.apache.iotdb.cluster.utils.ClusterConfigureGenerator;
+import org.apache.iotdb.jdbc.Config;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class IoTDBMetadataFetchRemoteIT extends IoTDBMetadataFetchAbstract{
+  @BeforeClass
+  public static void  setUp() throws Exception {
+    Class.forName(Config.JDBC_DRIVER_NAME);
+    ClusterConfigureGenerator.generateClusterConfigure();
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    ClusterConfigureGenerator.deleteClusterConfigure();
+  }
+
+  @Test
+  public void test3Node3Replicator() throws SQLException, IOException {
+//    final String URL = "192.168.130.16:6667/";
+//    String dir = Utils.getCurrentPath("pwd");
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "3", "3", dir);
+//    test(URL, false);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "3", dir);
+
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "3", "3", dir);
+//    test(URL, true);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "3", dir);
+  }
+
+
+  @Test
+  public void test3Node1Replicator() throws SQLException, IOException {
+//    final String URL = "192.168.130.16:6667/";
+//    String dir = Utils.getCurrentPath("pwd");
+//
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "3", "1", dir);
+//    test(URL, false);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "3", dir);
+//
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "3", "1", dir);
+//    test(URL, true);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "3", dir);
+  }
+
+  @Test
+  public void test5Node3Replicator() throws SQLException, IOException {
+//    final String URL = "192.168.130.16:6667/";
+//    String dir = Utils.getCurrentPath("pwd");
+//
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "5", "3", dir);
+//    test(URL, false);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "5", dir);
+//
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"deploy.sh",
+//        "5", "3", dir);
+//    test(URL, true);
+//    startScript("sh", dir + File.separator + "script" + File.separator + 
"stop.sh",
+//        "5", dir);
+  }
+
+  private void startScript(String... command) throws IOException{
+    ProcessBuilder builder = new ProcessBuilder(command);
+    builder.redirectErrorStream(true);
+    Process p = builder.start();
+    BufferedReader r = new BufferedReader(new 
InputStreamReader(p.getInputStream()));
+    String line;
+    while (true) {
+      line = r.readLine();
+      if (line == null) {
+        break;
+      } else {
+        System.out.println(line);
+      }
+    }
+    r.close();
+    p.destroy();
+  }
+
+
+}
+
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/qp/ClusterQPExecutorTest.java 
b/cluster/src/test/java/org/apache/iotdb/cluster/qp/ClusterQPExecutorTest.java
index 60d41b7..b430f02 100644
--- 
a/cluster/src/test/java/org/apache/iotdb/cluster/qp/ClusterQPExecutorTest.java
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/qp/ClusterQPExecutorTest.java
@@ -22,14 +22,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
 import org.apache.iotdb.cluster.config.ClusterConfig;
 import org.apache.iotdb.cluster.config.ClusterDescriptor;
 import org.apache.iotdb.cluster.qp.executor.NonQueryExecutor;
 import org.apache.iotdb.cluster.rpc.service.TSServiceClusterImpl;
-import org.apache.iotdb.cluster.utils.EnvironmentUtils;
-import org.apache.iotdb.db.exception.FileNodeManagerException;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
index 038505f..a8d413d 100644
--- 
a/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
@@ -22,13 +22,13 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.Collections;
 import org.apache.iotdb.cluster.config.ClusterConfig;
-import org.apache.iotdb.cluster.utils.EnvironmentUtils;
 import org.apache.iotdb.db.metadata.MManager;
 import org.apache.iotdb.db.qp.QueryProcessor;
 import org.apache.iotdb.db.qp.executor.OverflowQPExecutor;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.DeletePlan;
 import org.apache.iotdb.db.qp.physical.sys.MetadataPlan;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/utils/ClusterConfigureGenerator.java
 
b/cluster/src/test/java/org/apache/iotdb/cluster/utils/ClusterConfigureGenerator.java
new file mode 100644
index 0000000..10e109b
--- /dev/null
+++ 
b/cluster/src/test/java/org/apache/iotdb/cluster/utils/ClusterConfigureGenerator.java
@@ -0,0 +1,95 @@
+/**
+ * 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.cluster.utils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.io.FileUtils;
+import org.apache.iotdb.cluster.config.ClusterConfig;
+import org.apache.iotdb.cluster.config.ClusterDescriptor;
+
+public class ClusterConfigureGenerator {
+
+  private static final String TEST_CONF_PATH = "src" + File.separatorChar + 
"test"
+      + File.separatorChar + "resources" + File.separatorChar + "conf";
+  private static ClusterConfig config = 
ClusterDescriptor.getInstance().getConfig();
+  private static Map<String, String> configMap = new HashMap<String, String>() 
{
+    {
+      put("port", config.getPort() + "");
+      put("raft_log_path", config.getRaftLogPath() + "");
+      put("raft_snapshot_path", config.getRaftSnapshotPath() + "");
+      put("raft_metadata_path", config.getRaftMetadataPath() + "");
+      put("election_timeout_ms", config.getElectionTimeoutMs() + "");
+      put("max_catch_up_log_num", config.getMaxCatchUpLogNum() + "");
+      put("delay_snapshot", config.isDelaySnapshot() + "");
+      put("delay_hours", config.getDelayHours() + "");
+      put("task_redo_count", config.getTaskRedoCount() + "");
+      put("task_timeout_ms", config.getTaskTimeoutMs() + "");
+      put("num_of_virtual_nodes", config.getNumOfVirtualNodes() + "");
+      put("max_num_of_inner_rpc_client", config.getMaxNumOfInnerRpcClient() + 
"");
+      put("max_queue_num_of_inner_rpc_client", 
config.getMaxQueueNumOfInnerRpcClient() + "");
+      put("read_metadata_consistency_level", 
config.getReadMetadataConsistencyLevel() + "");
+      put("read_data_consistency_level", config.getReadDataConsistencyLevel() 
+ "");
+    }
+  };
+
+  public static void generateClusterConfigure() throws IOException {
+    deleteClusterConfigure();
+    File f = new File(TEST_CONF_PATH);
+    FileUtils.forceMkdir(f);
+    String[][] config = {
+        {"192.168.130.14:8888,192.168.130.16:8888,192.168.130.18:8888", "1"},
+        {"192.168.130.14:8888,192.168.130.16:8888,192.168.130.18:8888", "3"},
+        
{"192.168.130.12:8888,192.168.130.14:8888,192.168.130.16:8888,192.168.130.18:8888,192.168.130.19:8888",
 "3"},
+    };
+    for(String[] c : config){
+      for(String node : c[0].split(",")){
+        createConfigureFile(c[0], node.split(":")[0], c[1]);
+      }
+    }
+  }
+
+  public static void deleteClusterConfigure() throws IOException {
+    File f = new File(TEST_CONF_PATH);
+    if (f.exists() && f.isDirectory()) {
+      FileUtils.deleteDirectory(f);
+    }
+  }
+
+  private static void createConfigureFile(String nodes, String ip, String 
replicator)
+      throws IOException {
+    int nodeNum = nodes.split(",").length;
+
+    File configureFile = new File(TEST_CONF_PATH + File.separatorChar +
+        String.format("%d-%s-%s.properties",nodeNum, replicator, 
ip.split("\\.")[3]));
+    FileWriter writer = new FileWriter(configureFile, false);
+    for (Entry<String, String> entry : configMap.entrySet()) {
+      writer.write(String.format("%s=%s%s", entry.getKey(),
+          entry.getValue(), System.getProperty("line.separator")));
+    }
+    writer.write(String.format("%s=%s%s", "nodes", nodes, 
System.getProperty("line.separator")));
+    writer.write(String.format("%s=%s%s", "replication", replicator, 
System.getProperty("line.separator")));
+    writer.write(String.format("%s=%s%s", "ip", ip, 
System.getProperty("line.separator")));
+    writer.close();
+  }
+}
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/utils/EnvironmentUtils.java 
b/cluster/src/test/java/org/apache/iotdb/cluster/utils/EnvironmentUtils.java
deleted file mode 100644
index 63175aa..0000000
--- a/cluster/src/test/java/org/apache/iotdb/cluster/utils/EnvironmentUtils.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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.cluster.utils;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.iotdb.cluster.config.ClusterConfig;
-import org.apache.iotdb.cluster.config.ClusterDescriptor;
-import org.apache.iotdb.db.auth.AuthException;
-import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
-import org.apache.iotdb.db.auth.authorizer.LocalFileAuthorizer;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.conf.directories.Directories;
-import org.apache.iotdb.db.engine.cache.RowGroupBlockMetaDataCache;
-import org.apache.iotdb.db.engine.cache.TsFileMetaDataCache;
-import org.apache.iotdb.db.engine.filenode.FileNodeManager;
-import org.apache.iotdb.db.engine.memcontrol.BasicMemController;
-import org.apache.iotdb.db.exception.FileNodeManagerException;
-import org.apache.iotdb.db.exception.StartupException;
-import org.apache.iotdb.db.metadata.MManager;
-import org.apache.iotdb.db.monitor.StatMonitor;
-import org.apache.iotdb.db.query.context.QueryContext;
-import org.apache.iotdb.db.query.control.FileReaderManager;
-import org.apache.iotdb.db.query.control.QueryResourceManager;
-import org.apache.iotdb.db.writelog.manager.MultiFileLogNodeManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class is used for cleaning cluster test environment in unit test and 
integration test
- */
-public class EnvironmentUtils {
-  private static final Logger LOGGER = 
LoggerFactory.getLogger(EnvironmentUtils.class);
-
-  private static ClusterConfig clusterConfig = 
ClusterDescriptor.getInstance().getConfig();
-  private static IoTDBConfig config = 
IoTDBDescriptor.getInstance().getConfig();
-  private static Directories directories = Directories.getInstance();
-
-  public static long TEST_QUERY_JOB_ID = 
QueryResourceManager.getInstance().assignJobId();
-  public static QueryContext TEST_QUERY_CONTEXT = new 
QueryContext(TEST_QUERY_JOB_ID);
-
-  public static void cleanEnv() throws IOException, FileNodeManagerException {
-
-    QueryResourceManager.getInstance().endQueryForGivenJob(TEST_QUERY_JOB_ID);
-
-    // clear opened file streams
-    FileReaderManager.getInstance().closeAndRemoveAllOpenedReaders();
-
-    // tsFileConfig.duplicateIncompletedPage = false;
-    // clean filenode manager
-    try {
-      if (!FileNodeManager.getInstance().deleteAll()) {
-        LOGGER.error("Can't close the filenode manager in EnvironmentUtils");
-        System.exit(1);
-      }
-    } catch (FileNodeManagerException e) {
-      throw new IOException(e);
-    }
-    StatMonitor.getInstance().close();
-    FileNodeManager.getInstance().resetFileNodeManager();
-    // clean wal
-    MultiFileLogNodeManager.getInstance().stop();
-    // clean cache
-    TsFileMetaDataCache.getInstance().clear();
-    RowGroupBlockMetaDataCache.getInstance().clear();
-    // close metadata
-    MManager.getInstance().clear();
-    MManager.getInstance().flushObjectToFile();
-    // delete all directory
-    cleanAllDir();
-    // FileNodeManager.getInstance().reset();
-    // reset MemController
-    BasicMemController.getInstance().close();
-    try {
-      BasicMemController.getInstance().start();
-    } catch (StartupException e) {
-      LOGGER.error("", e);
-    }
-  }
-
-  private static void cleanAllDir() throws IOException {
-    // delete bufferwrite
-    for (String path : directories.getAllTsFileFolders()) {
-      cleanDir(path);
-    }
-    // delete overflow
-    cleanDir(config.getOverflowDataDir());
-    // delete filenode
-    cleanDir(config.getFileNodeDir());
-    // delete metadata
-    cleanDir(config.getMetadataDir());
-    // delete wal
-    cleanDir(config.getWalFolder());
-    // delete derby
-    cleanDir(config.getDerbyHome());
-    // delete index
-    cleanDir(config.getIndexFileDir());
-    // delete raft
-    clusterConfig.deleteAllPath();
-    // delte data
-    cleanDir("data");
-    // delte derby log
-    // cleanDir("derby.log");
-  }
-
-  public static void cleanDir(String dir) throws IOException {
-    File file = new File(dir);
-    if (file.exists()) {
-      if (file.isDirectory()) {
-        for (File subFile : file.listFiles()) {
-          cleanDir(subFile.getAbsolutePath());
-        }
-      }
-      if (!file.delete()) {
-        throw new IOException(String.format("The file %s can't be deleted", 
dir));
-      }
-    }
-  }
-
-  public static void envSetUp() throws StartupException {
-    // disable the memory control
-    config.setEnableMemMonitor(false);
-    // disable the system monitor
-    config.setEnableStatMonitor(false);
-    IAuthorizer authorizer;
-    try {
-      authorizer = LocalFileAuthorizer.getInstance();
-    } catch (AuthException e) {
-      throw new StartupException(e.getMessage());
-    }
-    try {
-      authorizer.reset();
-    } catch (AuthException e) {
-      throw new StartupException(e.getMessage());
-    }
-    FileNodeManager.getInstance().resetFileNodeManager();
-    MultiFileLogNodeManager.getInstance().start();
-    TEST_QUERY_JOB_ID = QueryResourceManager.getInstance().assignJobId();
-    TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID);
-  }
-}
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/utils/Utils.java 
b/cluster/src/test/java/org/apache/iotdb/cluster/utils/Utils.java
new file mode 100644
index 0000000..eb6e84d
--- /dev/null
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/utils/Utils.java
@@ -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.
+ */
+package org.apache.iotdb.cluster.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class Utils {
+  public static String getCurrentPath(String... command) throws IOException {
+    ProcessBuilder builder = new ProcessBuilder(command);
+    builder.redirectErrorStream(true);
+    Process p = builder.start();
+    BufferedReader r = new BufferedReader(new 
InputStreamReader(p.getInputStream()));
+    String path = r.readLine();
+    return path;
+  }
+}
diff --git 
a/cluster/src/test/java/org/apache/iotdb/cluster/utils/hash/RouterTest.java 
b/cluster/src/test/java/org/apache/iotdb/cluster/utils/hash/RouterTest.java
index b8b0563..cce8b61 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/utils/hash/RouterTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/utils/hash/RouterTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.*;
 
 import org.apache.iotdb.cluster.config.ClusterConfig;
 import org.apache.iotdb.cluster.config.ClusterDescriptor;
-import org.apache.iotdb.cluster.utils.EnvironmentUtils;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

Reply via email to