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 8804dd2  add client ip in thrift
8804dd2 is described below

commit 8804dd27f975a8dd945f2a1c0b357ec0b225b474
Author: xiangdong huang <[email protected]>
AuthorDate: Tue Dec 15 23:30:56 2020 +0800

    add client ip in thrift
---
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  | 23 ++++++++++++++++------
 thrift/src/main/thrift/cluster.thrift              |  3 ++-
 2 files changed, 19 insertions(+), 7 deletions(-)

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 63ddbac..11e4c2a 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
@@ -18,19 +18,16 @@
  */
 package org.apache.iotdb.db.conf;
 
+import com.google.common.net.InetAddresses;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.InetAddress;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.UnknownHostException;
 import java.util.Properties;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
 import org.apache.iotdb.db.conf.directories.DirectoryManager;
 import org.apache.iotdb.db.engine.compaction.CompactionStrategy;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -49,6 +46,7 @@ public class IoTDBDescriptor {
 
   protected IoTDBDescriptor() {
     loadProps();
+
   }
 
   public static IoTDBDescriptor getInstance() {
@@ -137,6 +135,7 @@ public class IoTDBDescriptor {
           ));
 
       conf.setRpcAddress(properties.getProperty("rpc_address", 
conf.getRpcAddress()));
+      replaceHostnameWithIP();
 
       conf.setRpcThriftCompressionEnable(
           
Boolean.parseBoolean(properties.getProperty("rpc_thrift_compression_enable",
@@ -569,6 +568,18 @@ public class IoTDBDescriptor {
     }
   }
 
+  // to keep consistent with the cluster module.
+  private void replaceHostnameWithIP() throws UnknownHostException {
+    boolean isInvalidRpcIp = InetAddresses.isInetAddress(conf.getRpcAddress());
+    if (!isInvalidRpcIp) {
+      InetAddress address = InetAddress.getByName(getConfig().getRpcAddress());
+      getConfig().setRpcAddress(address.getHostAddress());
+    }
+    logger.debug("after replace, the rpc_address={},", conf.getRpcAddress());
+  }
+
+
+
   private void loadWALProps(Properties properties) {
     conf.setEnableWal(Boolean.parseBoolean(properties.getProperty("enable_wal",
         Boolean.toString(conf.isEnableWal()))));
diff --git a/thrift/src/main/thrift/cluster.thrift 
b/thrift/src/main/thrift/cluster.thrift
index 6c86a1f..5c1d00c 100644
--- a/thrift/src/main/thrift/cluster.thrift
+++ b/thrift/src/main/thrift/cluster.thrift
@@ -113,7 +113,8 @@ struct Node {
   2: required int metaPort
   3: required int nodeIdentifier
   4: required int dataPort
-  5: required int clientPort
+  5: optional int clientPort
+  6: optional string clientIp
 }
 
 // leader -> follower

Reply via email to