timoninmaxim commented on code in PR #11841:
URL: https://github.com/apache/ignite/pull/11841#discussion_r1940770455


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -222,6 +277,26 @@ public File mkdirBinaryMeta() {
         return mkdir(binaryMeta, "binary metadata");
     }
 
+    /** @return {@code True} if WAL archive enabled. */
+    public boolean walArchiveEnabled() {
+        return walArchive != null && wal != null && !walArchive.equals(wal);
+    }
+
+    /**
+     * Creates a directory specified by the given arguments.
+     *
+     * @param cfg Configured directory path, may be {@code null}.

Review Comment:
   if `null` then `new File(null)` will throw NPE



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java:
##########
@@ -66,9 +63,8 @@ public SharedFileTree(File root) {
         A.notNull(root, "Root directory");
 
         this.root = root;
-        db = new File(root, DB_DEFAULT_FOLDER);
-        marshaller = new File(db, MARSHALLER_DIR);
-        binaryMetaRoot = new File(db, BINARY_METADATA_DIR);
+        marshaller = new File(root, DB_DEFAULT_FOLDER + "/" + MARSHALLER_DIR);

Review Comment:
   Use `Paths.get()` instead



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -222,6 +277,26 @@ public File mkdirBinaryMeta() {
         return mkdir(binaryMeta, "binary metadata");
     }
 
+    /** @return {@code True} if WAL archive enabled. */
+    public boolean walArchiveEnabled() {
+        return walArchive != null && wal != null && !walArchive.equals(wal);
+    }
+
+    /**
+     * Creates a directory specified by the given arguments.
+     *
+     * @param cfg Configured directory path, may be {@code null}.
+     * @return Initialized directory.
+     * @throws IgniteCheckedException If failed to initialize directory.
+     */
+    private File resolveDirectory(String cfg) {
+        File sharedBetweenNodesDir = new File(cfg);

Review Comment:
   just `sharedDir`. 



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -222,6 +277,26 @@ public File mkdirBinaryMeta() {
         return mkdir(binaryMeta, "binary metadata");
     }
 
+    /** @return {@code True} if WAL archive enabled. */
+    public boolean walArchiveEnabled() {
+        return walArchive != null && wal != null && !walArchive.equals(wal);
+    }
+
+    /**
+     * Creates a directory specified by the given arguments.
+     *
+     * @param cfg Configured directory path, may be {@code null}.
+     * @return Initialized directory.
+     * @throws IgniteCheckedException If failed to initialize directory.

Review Comment:
   never throws



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -222,6 +290,33 @@ public File mkdirBinaryMeta() {
         return mkdir(binaryMeta, "binary metadata");
     }
 
+    /** @return {@code True} if WAL archive enabled. */
+    public boolean walArchiveEnabled() {
+        return walArchive != null && wal != null && !walArchive.equals(wal);
+    }
+
+    /**
+     * Creates a directory specified by the given arguments.
+     *
+     * @param cfg Configured directory path, may be {@code null}.
+     * @return Initialized directory.
+     * @throws IgniteCheckedException If failed to initialize directory.
+     */
+    private File resolveDirectory(String cfg) {
+        File sharedBetweenNodesDir = new File(cfg);
+
+        return sharedBetweenNodesDir.isAbsolute()
+            ? new File(sharedBetweenNodesDir, folderName)
+            : new File(new File(root, cfg), folderName);
+    }
+
+    /**
+     * @return Default node directory, if {@link 
DataStorageConfiguration#getStoragePath()} is {@code null}.
+     */
+    private File defaultNodeStorage() {
+        return new File(new File(root, DB_DEFAULT_FOLDER), folderName);

Review Comment:
   Use paths `Paths.get().toFile()` instead



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -196,23 +224,63 @@ public NodeFileTree(File root, String folderName) {
     public NodeFileTree(IgniteConfiguration cfg, String folderName) {
         super(cfg);
 
-        A.notNullOrEmpty(folderName, "Node directory");
+        A.notNull(folderName, "Node directory");
 
         this.folderName = folderName;
 
         binaryMeta = new File(binaryMetaRoot, folderName);
+
+        DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration();
+
+        if (CU.isPersistenceEnabled(cfg) || CU.isCdcEnabled(cfg)) {
+            nodeStorage = dsCfg.getStoragePath() == null
+                ? defaultNodeStorage()
+                : resolveDirectory(dsCfg.getStoragePath());
+
+            wal = resolveDirectory(dsCfg.getWalPath());
+            walArchive = resolveDirectory(dsCfg.getWalArchivePath());
+            walCdc = resolveDirectory(dsCfg.getCdcWalPath());
+        }
+        else {
+            nodeStorage = null;
+            wal = null;
+            walArchive = null;
+            walCdc = null;
+        }
     }
 
     /** @return Folder name. */
     public String folderName() {
         return folderName;
     }
 
+    /**
+     * @return Node storage directory.

Review Comment:
   Should be online javadoc, similar to other methods



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java:
##########
@@ -196,23 +224,63 @@ public NodeFileTree(File root, String folderName) {
     public NodeFileTree(IgniteConfiguration cfg, String folderName) {
         super(cfg);
 
-        A.notNullOrEmpty(folderName, "Node directory");
+        A.notNull(folderName, "Node directory");
 
         this.folderName = folderName;
 
         binaryMeta = new File(binaryMetaRoot, folderName);
+
+        DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration();
+
+        if (CU.isPersistenceEnabled(cfg) || CU.isCdcEnabled(cfg)) {
+            nodeStorage = dsCfg.getStoragePath() == null
+                ? defaultNodeStorage()
+                : resolveDirectory(dsCfg.getStoragePath());
+
+            wal = resolveDirectory(dsCfg.getWalPath());
+            walArchive = resolveDirectory(dsCfg.getWalArchivePath());
+            walCdc = resolveDirectory(dsCfg.getCdcWalPath());
+        }
+        else {
+            nodeStorage = null;
+            wal = null;
+            walArchive = null;
+            walCdc = null;
+        }
     }
 
     /** @return Folder name. */
     public String folderName() {

Review Comment:
   Not used anymore



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to