You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/10/21 07:26:37 UTC

[GitHub] [incubator-iotdb] JackieTien97 commented on a change in pull request #429: [IOTDB-205]Support storage-group-level data ttl

JackieTien97 commented on a change in pull request #429: [IOTDB-205]Support storage-group-level data ttl
URL: https://github.com/apache/incubator-iotdb/pull/429#discussion_r336868641
 
 

 ##########
 File path: server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
 ##########
 @@ -580,6 +610,65 @@ public void syncDeleteDataFiles() {
     }
   }
 
+  /**
+   * Iterate each TsFile and try to lock and remove those out of TTL.
+   */
+  public synchronized void checkFilesTTL() {
+    if (dataTTL == Long.MAX_VALUE) {
+      logger.debug("{}: TTL not set, ignore the check", storageGroupName);
+      return;
+    }
+    long timeBound = System.currentTimeMillis() - dataTTL;
+    if (logger.isDebugEnabled()) {
+      logger.debug("{}: TTL removing files before {}", storageGroupName, new Date(timeBound));
+    }
+    // copy to avoid concurrent modification of deletion
+    List<TsFileResource> seqFiles = new ArrayList<>(sequenceFileList);
+    List<TsFileResource> unseqFiles = new ArrayList<>(unSequenceFileList);
+
+    for (TsFileResource tsFileResource : seqFiles) {
+      checkFileTTL(tsFileResource, timeBound, true);
+    }
+    for (TsFileResource tsFileResource : unseqFiles) {
+      checkFileTTL(tsFileResource, timeBound, false);
+    }
 
 Review comment:
   Why not use Iterator.remove() to avoid concurrent modification of deletion? It can also save the extra list copy time and space.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services