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

marklau99 pushed a commit to branch IOTDB-3771
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 4c185795c5638cc82420d9749583145608a8d2f3
Author: Liu Xuxin <[email protected]>
AuthorDate: Thu Jul 21 14:01:15 2022 +0800

    temp
---
 .../iotdb/db/engine/snapshot/SnapshotTaker.java    | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java 
b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
index 4796b66ac8..9297967df5 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
@@ -64,6 +64,7 @@ public class SnapshotTaker {
       throw new DirectoryNotLegalException(
           String.format("%s already exists and is not empty", 
snapshotDirPath));
     }
+    boolean inSameDisk = isSnapshotDirAndDataDirOnSameDisk(snapshotDir);
     seqBaseDir =
         new File(
             snapshotDir,
@@ -196,4 +197,30 @@ public class SnapshotTaker {
       }
     }
   }
+
+  private void createSnapshotInLocalDisk(File snapshotDir) {}
+
+  private void createSnapshotInAnotherDisk(File snapshotDir) {}
+
+  private boolean isSnapshotDirAndDataDirOnSameDisk(File snapshotDir) throws 
IOException {
+    String testFileName = "test";
+    File testFile = new File(snapshotDir, testFileName);
+    if (!testFile.createNewFile()) {
+      throw new IOException(
+          "Failed to test whether the data dir and snapshot dir is on the same 
disk");
+    }
+    String[] dataDirs = 
IoTDBDescriptor.getInstance().getConfig().getDataDirs();
+    for (String dataDir : dataDirs) {
+      File dirFile = new File(dataDir);
+      File testSnapshotFile = new File(dirFile, testFileName);
+      try {
+        Files.createLink(testFile.toPath(), testSnapshotFile.toPath());
+      } catch (IOException e) {
+        return false;
+      }
+      testSnapshotFile.delete();
+    }
+    testFile.delete();
+    return true;
+  }
 }

Reply via email to