samperson1997 commented on a change in pull request #1384:
URL: https://github.com/apache/incubator-iotdb/pull/1384#discussion_r443366958



##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -1702,4 +1766,31 @@ public void cacheSchema(String path, MeasurementSchema 
schema) {
       mRemoteSchemaCache.put(path, schema);
     }
   }
+
+  private void checkMTreeModified() {
+    if (System.currentTimeMillis() - logFile.lastModified() < 60 * 60 * 1000) {
+      logger.info("MTree snapshot is not created because of active 
modification");
+    } else if (logWriter.getLineNumber() - lastSnapshotLogLineNumber < 
mtreeSnapshotInterval) {
+      logger.info("MTree snapshot need not be created");
+    } else {
+      lock.writeLock().lock();
+      logger.info("Start creating MTree snapshot. This may take a while...");
+      try {
+        mtree.serializeTo(mtreeSnapshotTmpPath, logWriter.getLineNumber());
+        lastSnapshotLogLineNumber = logWriter.getLineNumber();
+        File tmpFile = 
SystemFileFactory.INSTANCE.getFile(mtreeSnapshotTmpPath);
+        File snapshotFile = 
SystemFileFactory.INSTANCE.getFile(mtreeSnapshotPath);
+        if (snapshotFile.exists()) {
+          Files.delete(snapshotFile.toPath());
+        }
+        if (tmpFile.renameTo(snapshotFile)) {
+          logger.info("Finish creating MTree snapshot to {}.", 
mtreeSnapshotPath);
+        }
+      } catch (IOException e) {
+        logger.warn("Failed to create MTree snapshot to {}", 
mtreeSnapshotPath, e);

Review comment:
       No need. It will be removed when restarting




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to