You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2022/04/14 04:30:09 UTC

[iotdb] branch metric_dependency_resolve created (now b9a8581a84)

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

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


      at b9a8581a84 init

This branch includes the following new commits:

     new b9a8581a84 init

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: init

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b9a8581a8439de7c669bb22242ab925e4a101dc6
Author: LebronAl <TX...@gmail.com>
AuthorDate: Thu Apr 14 12:29:47 2022 +0800

    init
---
 confignode/src/assembly/resources/conf/logback.xml     |  2 +-
 .../thrift/server/ConfigNodeRPCServerProcessor.java    |  1 +
 .../iotdb/confignode/consensus/RatisConsensusDemo.java | 11 +++++++----
 consensus/pom.xml                                      | 13 +++++++++----
 .../apache/iotdb/consensus/ratis/RatisConsensus.java   | 11 +++++++----
 server/pom.xml                                         | 18 ------------------
 .../org/apache/iotdb/db/client/ConfigNodeClient.java   |  1 +
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java     |  3 ++-
 .../java/org/apache/iotdb/db/service/DataNode.java     |  8 ++++++--
 9 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/confignode/src/assembly/resources/conf/logback.xml b/confignode/src/assembly/resources/conf/logback.xml
index 4e8e0d6275..7d9ac70f67 100644
--- a/confignode/src/assembly/resources/conf/logback.xml
+++ b/confignode/src/assembly/resources/conf/logback.xml
@@ -127,7 +127,7 @@
             <level>INFO</level>
         </filter>
     </appender>
-    <root level="info">
+    <root level="debug">
         <appender-ref ref="FILEDEBUG"/>
         <appender-ref ref="FILEWARN"/>
         <appender-ref ref="FILEERROR"/>
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/server/ConfigNodeRPCServerProcessor.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/server/ConfigNodeRPCServerProcessor.java
index 6bcb05877e..7da25479df 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/server/ConfigNodeRPCServerProcessor.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/server/ConfigNodeRPCServerProcessor.java
@@ -84,6 +84,7 @@ public class ConfigNodeRPCServerProcessor implements ConfigIService.Iface {
 
     TDataNodeRegisterResp resp = new TDataNodeRegisterResp();
     dataSet.convertToRpcDataNodeRegisterResp(resp);
+    LOGGER.error("{}", resp);
     return resp;
   }
 
diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/RatisConsensusDemo.java b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/RatisConsensusDemo.java
index 696d85a538..9348655d81 100644
--- a/confignode/src/test/java/org/apache/iotdb/confignode/consensus/RatisConsensusDemo.java
+++ b/confignode/src/test/java/org/apache/iotdb/confignode/consensus/RatisConsensusDemo.java
@@ -34,6 +34,7 @@ import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 import org.junit.Assert;
+import org.junit.Test;
 
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -55,6 +56,7 @@ public class RatisConsensusDemo {
    * ConfigNode by yourself 5. Add @Test 6. run ratisConsensusRegisterDemo 7. run
    * ratisConsensusQueryDemo
    */
+  @Test
   public void ratisConsensusSetStorageGroupsDemo() throws TException, InterruptedException {
     createClients();
     setStorageGroups();
@@ -65,6 +67,7 @@ public class RatisConsensusDemo {
     queryDataNodes();
   }
 
+  @Test
   public void ratisConsensusQueryStorageGroupsDemo() throws TException, InterruptedException {
     createClients();
     queryStorageGroups();
@@ -78,8 +81,8 @@ public class RatisConsensusDemo {
   private void createClients() throws TTransportException {
     // Create clients for these three ConfigNodes
     // to simulate DataNodes to send RPC requests
-    clients = new ConfigIService.Client[3];
-    for (int i = 0; i < 3; i++) {
+    clients = new ConfigIService.Client[1];
+    for (int i = 0; i < 1; i++) {
       TTransport transport =
           RpcTransportFactory.INSTANCE.getTransport(localhost, 22277 + i * 2, timeOutInMS);
       transport.open();
@@ -107,7 +110,7 @@ public class RatisConsensusDemo {
     TimeUnit.SECONDS.sleep(1);
 
     // DataNodes can connect to any ConfigNode and send read requests
-    for (int i = 0; i < 3; i++) {
+    for (int i = 0; i < 1; i++) {
       TDataNodeMessageResp msgMap = clients[i].getDataNodesMessage(-1);
       System.out.printf(
           "\nQuery DataNode message from ConfigNode 0.0.0.0:%d. Result: %s\n",
@@ -128,7 +131,7 @@ public class RatisConsensusDemo {
     // sleep 1s to make sure all ConfigNode in ConfigNodeGroup hold the same PartitionTable
     TimeUnit.SECONDS.sleep(1);
 
-    for (int i = 0; i < 3; i++) {
+    for (int i = 0; i < 1; i++) {
       TStorageGroupSchemaResp msgMap = clients[i].getStorageGroupsSchema();
       System.out.printf(
           "\nQuery StorageGroup message from ConfigNode 0.0.0.0:%d. Result: {\n", 22277 + i * 2);
diff --git a/consensus/pom.xml b/consensus/pom.xml
index f668d8b4bd..bdb355d8b6 100644
--- a/consensus/pom.xml
+++ b/consensus/pom.xml
@@ -38,13 +38,18 @@
         </dependency>
         <dependency>
             <groupId>org.apache.ratis</groupId>
-            <artifactId>ratis-grpc</artifactId>
+            <artifactId>ratis-common</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ratis</groupId>
+            <artifactId>ratis-netty</artifactId>
             <version>2.2.0</version>
         </dependency>
         <dependency>
-            <groupId>io.dropwizard.metrics</groupId>
-            <artifactId>metrics-core</artifactId>
-            <version>3.2.5</version>
+            <groupId>org.apache.ratis</groupId>
+            <artifactId>ratis-grpc</artifactId>
+            <version>2.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.iotdb</groupId>
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index b42b57b77a..91acd7b106 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -37,11 +37,12 @@ import org.apache.iotdb.consensus.exception.PeerNotInConsensusGroupException;
 import org.apache.iotdb.consensus.exception.RatisRequestFailedException;
 import org.apache.iotdb.consensus.statemachine.IStateMachine;
 
+import org.apache.ratis.RaftConfigKeys;
 import org.apache.ratis.client.RaftClient;
 import org.apache.ratis.conf.Parameters;
 import org.apache.ratis.conf.RaftProperties;
-import org.apache.ratis.grpc.GrpcConfigKeys;
-import org.apache.ratis.grpc.GrpcFactory;
+import org.apache.ratis.netty.NettyConfigKeys;
+import org.apache.ratis.netty.NettyFactory;
 import org.apache.ratis.protocol.ClientId;
 import org.apache.ratis.protocol.GroupInfoReply;
 import org.apache.ratis.protocol.Message;
@@ -51,6 +52,7 @@ import org.apache.ratis.protocol.RaftGroup;
 import org.apache.ratis.protocol.RaftGroupId;
 import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.exceptions.NotLeaderException;
+import org.apache.ratis.rpc.SupportedRpcType;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.RaftServerConfigKeys;
 import org.apache.ratis.util.NetUtils;
@@ -105,10 +107,11 @@ class RatisConsensus implements IConsensus {
     RaftProperties properties = new RaftProperties();
 
     RaftServerConfigKeys.setStorageDir(properties, Collections.singletonList(ratisStorageDir));
+    RaftConfigKeys.Rpc.setType(properties, SupportedRpcType.NETTY);
 
     // set the port which server listen to in RaftProperty object
     final int port = NetUtils.createSocketAddr(address).getPort();
-    GrpcConfigKeys.Server.setPort(properties, port);
+    NettyConfigKeys.Server.setPort(properties, port);
 
     server =
         RaftServer.newBuilder()
@@ -508,7 +511,7 @@ class RatisConsensus implements IConsensus {
             .setProperties(raftProperties)
             .setRaftGroup(group)
             .setClientRpc(
-                new GrpcFactory(new Parameters())
+                new NettyFactory(new Parameters())
                     .newRaftClientRpc(ClientId.randomId(), raftProperties));
     RaftClient client = builder.build();
     closeRaftClient(group.getGroupId());
diff --git a/server/pom.xml b/server/pom.xml
index 6d3dfa22d3..4704e35300 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -128,14 +128,6 @@
             <groupId>io.dropwizard.metrics</groupId>
             <artifactId>metrics-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>io.dropwizard.metrics</groupId>
-            <artifactId>metrics-jvm</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.dropwizard.metrics</groupId>
-            <artifactId>metrics-json</artifactId>
-        </dependency>
         <dependency>
             <groupId>commons-cli</groupId>
             <artifactId>commons-cli</artifactId>
@@ -251,22 +243,12 @@
             <artifactId>micrometer-metrics</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.iotdb</groupId>
-            <artifactId>dropwizard-metrics</artifactId>
-            <version>${project.version}</version>
-        </dependency>
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
             <version>2.6</version>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>com.codahale.metrics</groupId>
-            <artifactId>metrics-core</artifactId>
-            <version>3.0.2</version>
-        </dependency>
         <dependency>
             <groupId>org.rocksdb</groupId>
             <artifactId>rocksdbjni</artifactId>
diff --git a/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java b/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
index a963ffe476..c3c5b610f7 100644
--- a/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
+++ b/server/src/main/java/org/apache/iotdb/db/client/ConfigNodeClient.java
@@ -157,6 +157,7 @@ public class ConfigNodeClient {
     for (int i = 0; i < RETRY_NUM; i++) {
       try {
         TDataNodeRegisterResp resp = client.registerDataNode(req);
+        logger.error("{}", resp);
         if (!updateConfigNodeLeader(resp.status)) {
           return resp;
         }
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 a7603576a1..f8b1242ba0 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
@@ -856,7 +856,7 @@ public class IoTDBConfig {
   private int consensusPort = 40010;
 
   /** The max time of data node waiting to join into the cluster */
-  private long joinClusterTimeOutMs = TimeUnit.SECONDS.toMillis(60);
+  private long joinClusterTimeOutMs = TimeUnit.SECONDS.toMillis(5);
 
   /**
    * The consensus protocol class. The Datanode should communicate with ConfigNode on startup and
@@ -896,6 +896,7 @@ public class IoTDBConfig {
       internalIp = "127.0.0.1";
     }
     configNodeUrls = new ArrayList<>();
+    configNodeUrls.add("127.0.0.1:22277");
   }
 
   public float getUdfMemoryBudgetInMB() {
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
index a14fe6feaa..2e1fb056e6 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -135,15 +135,19 @@ public class DataNode implements DataNodeMBean {
           logger.info("Joined the cluster successfully");
           return;
         }
+      } catch (IoTDBConnectionException e) {
+        logger.warn("Cannot join the cluster, because: {}", e.getMessage());
+      }
 
+      try {
         // wait 5s to start the next try
         Thread.sleep(IoTDBDescriptor.getInstance().getConfig().getJoinClusterTimeOutMs());
-      } catch (IoTDBConnectionException e) {
-        logger.warn("Cannot join the cluster, because: {}", e.getMessage());
       } catch (InterruptedException e) {
         Thread.currentThread().interrupt();
         logger.warn("Unexpected interruption when waiting to join the cluster", e);
+        break;
       }
+
       // start the next try
       retry--;
     }