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

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


The following commit(s) were added to refs/heads/xianyi by this push:
     new d452d3a  support server nodelist config and api
d452d3a is described below

commit d452d3ab5bd1681117d9a13637f02d1573bd3947
Author: LebronAl <[email protected]>
AuthorDate: Thu Nov 25 12:06:11 2021 +0800

    support server nodelist config and api
---
 .../resources/conf/iotdb-engine.properties         |  3 +++
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 10 ++++++++++
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |  2 ++
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 23 ++++++++++++++++------
 thrift/src/main/thrift/rpc.thrift                  |  2 ++
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties 
b/server/src/assembly/resources/conf/iotdb-engine.properties
index 48a6d2f..d661656 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -40,6 +40,9 @@ rpc_address=0.0.0.0
 # Datatype: int
 rpc_port=6667
 
+# Node list: string
+node_list=127.0.0.1:6667,127.0.0.1:6668,127.0.0.1:6669
+
 # Datatype: boolean
 # rpc_thrift_compression_enable=false
 
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 4e53f98..36771b1 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -74,6 +74,8 @@ public class IoTDBConfig {
   /** Port which the metrics service listens to. */
   private int metricsPort = 8181;
 
+  private String nodeList = "127.0.0.1:6667,127.0.0.1:6668,127.0.0.1:6669";
+
   private boolean enableMetricService = false;
 
   /** whether to enable the mqtt service. */
@@ -1469,6 +1471,14 @@ public class IoTDBConfig {
     this.enableExternalSort = enableExternalSort;
   }
 
+  public String getNodeList() {
+    return nodeList;
+  }
+
+  public void setNodeList(String nodeList) {
+    this.nodeList = nodeList;
+  }
+
   public int getExternalSortThreshold() {
     return externalSortThreshold;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 17deb09..77cabe9 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -144,6 +144,8 @@ public class IoTDBDescriptor {
           Integer.parseInt(
               properties.getProperty("metrics_port", 
Integer.toString(conf.getMetricsPort()))));
 
+      conf.setNodeList(properties.getProperty("node_list", 
conf.getNodeList()));
+
       conf.setQueryCacheSizeInMetric(
           Integer.parseInt(
               properties.getProperty(
diff --git 
a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java 
b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 93fe754..85636cf 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -142,6 +142,11 @@ import org.apache.iotdb.tsfile.read.filter.operator.Lt;
 import org.apache.iotdb.tsfile.read.filter.operator.LtEq;
 import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 
+import com.google.common.primitives.Bytes;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.sql.SQLException;
@@ -159,11 +164,7 @@ import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.ForkJoinTask;
 import java.util.concurrent.RecursiveTask;
 import java.util.stream.Collectors;
-
-import com.google.common.primitives.Bytes;
-import org.apache.thrift.TException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.stream.Stream;
 
 import static org.apache.iotdb.db.utils.ErrorHandlingUtils.onIoTDBException;
 import static 
org.apache.iotdb.db.utils.ErrorHandlingUtils.onNPEOrUnexpectedException;
@@ -201,7 +202,17 @@ public class TSServiceImpl extends BasicServiceProvider 
implements TSIService.If
         openSession(req.username, req.password, req.zoneId, 
req.client_protocol);
     TSStatus tsStatus = RpcUtils.getStatus(openSessionResp.getCode(), 
openSessionResp.getMessage());
     TSOpenSessionResp resp = new TSOpenSessionResp(tsStatus, 
CURRENT_RPC_VERSION);
-    return resp.setSessionId(openSessionResp.getSessionId());
+    return 
resp.setSessionId(openSessionResp.getSessionId()).setNodeList(genNodeList());
+  }
+
+  private List<EndPoint> genNodeList() {
+    return 
Stream.of(IoTDBDescriptor.getInstance().getConfig().getNodeList().split(","))
+        .map(
+            x -> {
+              String[] node = x.split(":");
+              return new EndPoint(node[0], Integer.parseInt(node[1]));
+            })
+        .collect(Collectors.toList());
   }
 
   @Override
diff --git a/thrift/src/main/thrift/rpc.thrift 
b/thrift/src/main/thrift/rpc.thrift
index 7a30ad8..1830e4c 100644
--- a/thrift/src/main/thrift/rpc.thrift
+++ b/thrift/src/main/thrift/rpc.thrift
@@ -97,6 +97,8 @@ struct TSOpenSessionResp {
 
   // The configuration settings for this session.
   4: optional map<string, string> configuration
+
+  5: optional list<EndPoint> nodeList;
 }
 
 // OpenSession()

Reply via email to