You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by yu...@apache.org on 2020/07/22 13:30:25 UTC

[incubator-iotdb] branch kyy2 updated: add max num of logs in mem config

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

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


The following commit(s) were added to refs/heads/kyy2 by this push:
     new 995dba5  add max num of logs in mem config
995dba5 is described below

commit 995dba58e02c03f29425f6d4ca13aa0c99d951bc
Author: Ring-k <yu...@hotmail.com>
AuthorDate: Wed Jul 22 21:29:52 2020 +0800

    add max num of logs in mem config
---
 .../src/assembly/resources/conf/iotdb-cluster.properties    |  2 ++
 .../java/org/apache/iotdb/cluster/config/ClusterConfig.java | 13 +++++++++++++
 .../org/apache/iotdb/cluster/config/ClusterDescriptor.java  |  3 +++
 .../org/apache/iotdb/cluster/log/manage/RaftLogManager.java | 12 ++++++------
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/cluster/src/assembly/resources/conf/iotdb-cluster.properties b/cluster/src/assembly/resources/conf/iotdb-cluster.properties
index 35b1dc3..1cca54b 100644
--- a/cluster/src/assembly/resources/conf/iotdb-cluster.properties
+++ b/cluster/src/assembly/resources/conf/iotdb-cluster.properties
@@ -83,3 +83,5 @@ enable_auto_create_schema=true
 # Weak consistency do not synchronize with the leader and simply use the local data
 consistency_level=mid
 
+max_num_of_logs_in_mem=100
+
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
index 83f0c2e..c1fd58e 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java
@@ -66,6 +66,11 @@ public class ClusterConfig {
   private int maxNumberOfLogs = 100;
 
   /**
+   * max number of committed logs in memory
+   */
+  private int maxNumOfLogsInMem = 100;
+
+  /**
    * deletion check period of the submitted log
    */
   private int logDeleteCheckIntervalSecond = 60;
@@ -266,4 +271,12 @@ public class ClusterConfig {
   public void setUseAsyncApplier(boolean useAsyncApplier) {
     this.useAsyncApplier = useAsyncApplier;
   }
+
+  public int getMaxNumOfLogsInMem() {
+    return maxNumOfLogsInMem;
+  }
+
+  public void setMaxNumOfLogsInMem(int maxNumOfLogsInMem) {
+    this.maxNumOfLogsInMem = maxNumOfLogsInMem;
+  }
 }
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 d0fb38e..74bd71b 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
@@ -226,6 +226,9 @@ public class ClusterDescriptor {
     config.setMaxNumberOfLogs(Integer.parseInt(
         properties.getProperty("max_number_of_logs", String.valueOf(config.getMaxNumberOfLogs()))));
 
+    config.setMaxNumOfLogsInMem(Integer.parseInt(properties
+        .getProperty("max_num_of_logs_in_mem", String.valueOf(config.getMaxNumOfLogsInMem()))));
+
     config.setLogDeleteCheckIntervalSecond(Integer.parseInt(properties
         .getProperty("log_deletion_check_interval_second",
             String.valueOf(config.getLogDeleteCheckIntervalSecond()))));
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/log/manage/RaftLogManager.java b/cluster/src/main/java/org/apache/iotdb/cluster/log/manage/RaftLogManager.java
index 66aae6a..e3850e6 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/log/manage/RaftLogManager.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/log/manage/RaftLogManager.java
@@ -157,8 +157,8 @@ public class RaftLogManager {
    * Returns the term for given index.
    *
    * @param index request entry index
-   * @return throw EntryCompactedException if index < dummyIndex, -1 if
-   * index > lastIndex, otherwise return the entry's term for given index
+   * @return throw EntryCompactedException if index < dummyIndex, -1 if index > lastIndex, otherwise
+   * return the entry's term for given index
    * @throws EntryCompactedException
    */
   public long getTerm(long index) throws EntryCompactedException {
@@ -580,10 +580,10 @@ public class RaftLogManager {
       long removeSize = committedEntryManager.getTotalSize() - maxNumberOfLogs;
       long compactIndex = committedEntryManager.getDummyIndex() + removeSize;
       try {
-        logger.info("{}: Before compaction index {}-{}, compactIndex {}, removeSize {}, "
-                + "committedLogSize {}",
-            name,
-            getFirstIndex(), getLastLogIndex(), compactIndex, removeSize, committedEntryManager.getTotalSize());
+        logger.info(
+            "{}: Before compaction index {}-{}, compactIndex {}, removeSize {}, committedLogSize {}",
+            name, getFirstIndex(), getLastLogIndex(), compactIndex, removeSize,
+            committedEntryManager.getTotalSize());
         getCommittedEntryManager().compactEntries(compactIndex);
         if (ClusterDescriptor.getInstance().getConfig().isEnableRaftLogPersistence()) {
           getStableEntryManager().removeCompactedEntries(compactIndex);