You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/09/24 01:50:37 UTC

[incubator-iotdb] branch dev_TTL updated: add a test and logs

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

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


The following commit(s) were added to refs/heads/dev_TTL by this push:
     new 5a6a434  add a test and logs
5a6a434 is described below

commit 5a6a434354845b559dad285e9a4924b76df9b9db
Author: jt <jt...@163.com>
AuthorDate: Tue Sep 24 09:39:34 2019 +0800

    add a test and logs
---
 .../db/engine/storagegroup/StorageGroupProcessor.java  |  8 ++++++--
 .../org/apache/iotdb/db/integration/IoTDBTtlIT.java    | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 12cfa96..74673fa 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -590,9 +590,13 @@ public class StorageGroupProcessor {
   }
 
   public synchronized void checkFilesTTL() {
+    if (dataTTL == Long.MAX_VALUE) {
+      logger.info("{}: TTL not set, ignore the check", storageGroupName);
+      return;
+    }
     long timeBound = System.currentTimeMillis() - dataTTL;
-    if (logger.isDebugEnabled()) {
-      logger.debug("TTL removing files before {}", new Date(timeBound));
+    if (logger.isInfoEnabled()) {
+      logger.info("{}: TTL removing files before {}", storageGroupName, new Date(timeBound));
     }
     try {
       for (TsFileResource tsFileResource : unSequenceFileList) {
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTtlIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTtlIT.java
index c45a687..0b99106 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTtlIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTtlIT.java
@@ -27,6 +27,7 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.service.IoTDB;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.jdbc.Config;
@@ -177,4 +178,21 @@ public class IoTDBTtlIT {
     }
     return ret.toString();
   }
+
+  @Test
+  public void testDefaultTTL() throws SQLException {
+    IoTDBDescriptor.getInstance().getConfig().setDefaultTTL(10000);
+    try (IoTDBConnection connection = (IoTDBConnection) DriverManager
+        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement()) {
+      statement.execute("SET STORAGE GROUP TO root.group1");
+      statement.execute("SET STORAGE GROUP TO root.group2");
+
+      String result = doQuery(statement, "SHOW ALL TTL",2 );
+      assertEquals("root.group2,10000\n"
+          + "root.group1,10000\n", result);
+    } finally {
+      IoTDBDescriptor.getInstance().getConfig().setDefaultTTL(Long.MAX_VALUE);
+    }
+  }
 }
\ No newline at end of file