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

nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b53e2af2d7 IGNITE-24425 Move cache dir filters to NodeFileTree 
(#11860)
7b53e2af2d7 is described below

commit 7b53e2af2d724abf3830cead53a54bde2ef838e0
Author: Nikolay <[email protected]>
AuthorDate: Tue Feb 11 15:35:47 2025 +0300

    IGNITE-24425 Move cache dir filters to NodeFileTree (#11860)
---
 ...gratingToWalV2SerializerWithCompactionTest.java |  2 +-
 .../apache/ignite/util/GridCommandHandlerTest.java |  4 +-
 .../processors/cache/GridLocalConfigManager.java   | 12 ++---
 .../persistence/file/FilePageStoreManager.java     | 45 +++---------------
 .../cache/persistence/filename/NodeFileTree.java   | 55 ++++++++++++++++++++--
 .../snapshot/IgniteSnapshotManager.java            |  6 +--
 .../snapshot/SnapshotPartitionsVerifyHandler.java  |  8 ++--
 .../snapshot/SnapshotRestoreProcess.java           | 15 +++---
 .../snapshot/dump/CreateDumpFutureTask.java        |  5 +-
 .../cache/persistence/snapshot/dump/Dump.java      | 17 ++-----
 .../processors/cache/verify/IdleVerifyUtility.java |  4 +-
 .../persistence/IgnitePdsDefragmentationTest.java  | 19 ++------
 .../PagesPossibleCorruptionDiagnosticTest.java     |  3 +-
 .../db/checkpoint/CheckpointFreeListTest.java      |  9 +---
 .../persistence/db/wal/WalCompactionTest.java      |  4 +-
 .../snapshot/AbstractSnapshotSelfTest.java         |  7 +--
 .../snapshot/IgniteClusterSnapshotDeltaTest.java   |  4 +-
 .../IgniteClusterSnapshotRestoreSelfTest.java      |  4 +-
 .../snapshot/dump/IgniteCacheDumpSelf2Test.java    |  8 ++--
 .../IgnitePdsIndexingDefragmentationTest.java      | 17 ++++---
 .../db/IgniteCacheGroupsWithRestartsTest.java      | 15 +-----
 .../persistence/db/wal/IgniteWalRecoveryTest.java  | 36 +++-----------
 .../WalDisabledDuringIndexRecreateTest.java        | 17 +++----
 23 files changed, 126 insertions(+), 190 deletions(-)

diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java
index 822b0b2563a..e505e58679e 100644
--- 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java
@@ -142,7 +142,7 @@ public class MigratingToWalV2SerializerWithCompactionTest 
extends IgnitePersiste
             assertNotNull(cpMarkers);
             assertTrue(cpMarkers.length > 0);
 
-            File cacheDir = new File(ft.nodeStorage(), "cache-" + 
TEST_CACHE_NAME);
+            File cacheDir = ft.cacheStorage(false, TEST_CACHE_NAME);
             File[] partFiles = cacheDir.listFiles(new FilenameFilter() {
                 @Override public boolean accept(File dir, String name) {
                     return name.startsWith("part");
diff --git 
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
 
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
index 9999a84df3f..c9fd80c9cc4 100644
--- 
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
+++ 
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
@@ -512,7 +512,7 @@ public class GridCommandHandlerTest extends 
GridCommandHandlerClusterPerMethodAb
 
         boolean allEmpty = Arrays.stream(mntcNodeWorkDir.listFiles())
             .filter(File::isDirectory)
-            .filter(f -> f.getName().startsWith("cache-"))
+            .filter(NodeFileTree::cacheDir)
             .map(f -> f.listFiles().length == 1)
             .reduce(true, (t, u) -> t && u);
 
@@ -555,7 +555,7 @@ public class GridCommandHandlerTest extends 
GridCommandHandlerClusterPerMethodAb
 
         Set<String> allCacheDirs = Arrays.stream(mntcNodeWorkDir.listFiles())
             .filter(File::isDirectory)
-            .filter(f -> f.getName().startsWith("cache-"))
+            .filter(NodeFileTree::cacheDir)
             .map(File::getName)
             .collect(Collectors.toCollection(TreeSet::new));
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java
index 0e3ffb8219b..8d074372114 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLocalConfigManager.java
@@ -70,8 +70,6 @@ import org.jetbrains.annotations.Nullable;
 import static java.nio.file.Files.newDirectoryStream;
 import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.UTILITY_CACHE_NAME;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.TMP_SUFFIX;
 import static 
org.apache.ignite.internal.processors.query.QueryUtils.normalizeObjectName;
 import static 
org.apache.ignite.internal.processors.query.QueryUtils.normalizeSchemaName;
@@ -238,10 +236,12 @@ public class GridLocalConfigManager {
         if (caches == null)
             return Collections.emptyMap();
 
+        String utilityCacheStorage = NodeFileTree.cacheDirName(false, 
UTILITY_CACHE_NAME);
+
         return Arrays.stream(caches)
             .filter(f -> f.isDirectory() &&
-                (f.getName().startsWith(CACHE_DIR_PREFIX) || 
f.getName().startsWith(CACHE_GRP_DIR_PREFIX)) &&
-                !f.getName().equals(CACHE_DIR_PREFIX + UTILITY_CACHE_NAME))
+                NodeFileTree.CACHE_DIR_FILTER.test(f) &&
+                !f.getName().equals(utilityCacheStorage))
             .filter(File::exists)
             .flatMap(cacheDir -> 
Arrays.stream(FilePageStoreManager.cacheDataFiles(cacheDir)))
             .collect(Collectors.toMap(f -> f, f -> {
@@ -467,7 +467,7 @@ public class GridLocalConfigManager {
      * @throws IgniteCheckedException If failed.
      */
     public void readCacheConfigurations(File dir, Map<String, StoredCacheData> 
ccfgs) throws IgniteCheckedException {
-        if (dir.getName().startsWith(CACHE_DIR_PREFIX)) {
+        if (NodeFileTree.cacheDir(dir)) {
             File conf = new File(dir, CACHE_DATA_FILENAME);
 
             if (conf.exists() && conf.length() > 0) {
@@ -478,7 +478,7 @@ public class GridLocalConfigManager {
                 );
             }
         }
-        else if (dir.getName().startsWith(CACHE_GRP_DIR_PREFIX))
+        else if (NodeFileTree.cacheGroupDir(dir))
             readCacheGroupCaches(dir, ccfgs);
     }
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
index 2bab7c563f1..ff69f3251ef 100755
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
@@ -88,6 +88,7 @@ import static java.nio.file.Files.newDirectoryStream;
 import static java.util.Objects.requireNonNull;
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.MAX_PARTITION_ID;
+import static 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.CACHE_DIR_WITH_META_FILTER;
 
 /**
  * File page store manager.
@@ -115,18 +116,6 @@ public class FilePageStoreManager extends 
GridCacheSharedManagerAdapter implemen
     /** */
     public static final String PART_FILE_TEMPLATE = PART_FILE_PREFIX + "%d" + 
FILE_SUFFIX;
 
-    /** */
-    public static final String CACHE_DIR_PREFIX = "cache-";
-
-    /** */
-    public static final String CACHE_GRP_DIR_PREFIX = "cacheGroup-";
-
-    /** */
-    public static final Predicate<File> DATA_DIR_FILTER = dir ->
-        dir.getName().startsWith(CACHE_DIR_PREFIX) ||
-        dir.getName().startsWith(CACHE_GRP_DIR_PREFIX) ||
-        dir.getName().equals(MetaStorage.METASTORAGE_DIR_NAME);
-
     /** */
     public static final String CACHE_DATA_FILENAME = "cache_data.dat";
 
@@ -271,12 +260,7 @@ public class FilePageStoreManager extends 
GridCacheSharedManagerAdapter implemen
     @Override public void cleanupPersistentSpace() throws 
IgniteCheckedException {
         try {
             try (DirectoryStream<Path> files = newDirectoryStream(
-                ft.nodeStorage().toPath(), entry -> {
-                    String name = entry.toFile().getName();
-
-                    return !name.equals(MetaStorage.METASTORAGE_DIR_NAME) &&
-                        (name.startsWith(CACHE_DIR_PREFIX) || 
name.startsWith(CACHE_GRP_DIR_PREFIX));
-                }
+                ft.nodeStorage().toPath(), entry -> 
NodeFileTree.CACHE_DIR_FILTER.test(entry.toFile())
             )) {
                 for (Path path : files)
                     U.delete(path);
@@ -837,8 +821,8 @@ public class FilePageStoreManager extends 
GridCacheSharedManagerAdapter implemen
         return Arrays.stream(files)
             .sorted()
             .filter(File::isDirectory)
-            .filter(DATA_DIR_FILTER)
-            .filter(f -> names.test(cacheGroupName(f)))
+            .filter(CACHE_DIR_WITH_META_FILTER)
+            .filter(f -> names.test(NodeFileTree.cacheName(f)))
             .collect(Collectors.toList());
     }
 
@@ -855,8 +839,8 @@ public class FilePageStoreManager extends 
GridCacheSharedManagerAdapter implemen
 
         return Arrays.stream(files)
             .filter(File::isDirectory)
-            .filter(DATA_DIR_FILTER)
-            .filter(f -> CU.cacheId(cacheGroupName(f)) == grpId)
+            .filter(CACHE_DIR_WITH_META_FILTER)
+            .filter(f -> CU.cacheId(NodeFileTree.cacheName(f)) == grpId)
             .findAny()
             .orElse(null);
     }
@@ -900,23 +884,6 @@ public class FilePageStoreManager extends 
GridCacheSharedManagerAdapter implemen
             .collect(Collectors.toList());
     }
 
-    /**
-     * @param dir Cache directory on disk.
-     * @return Cache or cache group name.
-     */
-    public static String cacheGroupName(File dir) {
-        String name = dir.getName();
-
-        if (name.startsWith(CACHE_GRP_DIR_PREFIX))
-            return name.substring(CACHE_GRP_DIR_PREFIX.length());
-        else if (name.startsWith(CACHE_DIR_PREFIX))
-            return name.substring(CACHE_DIR_PREFIX.length());
-        else if (name.equals(MetaStorage.METASTORAGE_DIR_NAME))
-            return MetaStorage.METASTORAGE_CACHE_NAME;
-        else
-            throw new IgniteException("Directory doesn't match the cache or 
cache group prefix: " + dir);
-    }
-
     /**
      * @param root Root directory.
      * @return Array of cache data files.
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java
index 0cb5aacb52d..46d3c9189a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java
@@ -19,9 +19,12 @@ package 
org.apache.ignite.internal.processors.cache.persistence.filename;
 
 import java.io.File;
 import java.nio.file.Paths;
+import java.util.function.Predicate;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -32,8 +35,6 @@ import org.jetbrains.annotations.Nullable;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_CDC_PATH;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER;
 
 /**
@@ -156,6 +157,20 @@ public class NodeFileTree extends SharedFileTree {
     /** Checkpoint directory name. */
     public static final String CHECKPOINT_DIR = "cp";
 
+    /** Prefix for {@link #cacheStorage(String)} directory in case of single 
cache. */
+    private static final String CACHE_DIR_PREFIX = "cache-";
+
+    /** Prefix for {@link #cacheStorage(String)} directory in case of cache 
group. */
+    private static final String CACHE_GRP_DIR_PREFIX = "cacheGroup-";
+
+    /** Filter out all cache directories. */
+    public static final Predicate<File> CACHE_DIR_FILTER = dir -> 
cacheDir(dir) || cacheGroupDir(dir);
+
+    /** Filter out all cache directories including {@link MetaStorage}. */
+    public static final Predicate<File> CACHE_DIR_WITH_META_FILTER = dir ->
+        CACHE_DIR_FILTER.test(dir) ||
+            dir.getName().equals(MetaStorage.METASTORAGE_DIR_NAME);
+
     /** Folder name for consistent id. */
     private final String folderName;
 
@@ -380,6 +395,23 @@ public class NodeFileTree extends SharedFileTree {
         return new File(storeWorkDir, cacheDirName);
     }
 
+    /**
+     * @param dir Directory.
+     * @return {@code True} if directory conforms cache storage name pattern.
+     * @see #cacheGroupDir(File)
+     */
+    public static boolean cacheDir(File dir) {
+        return dir.getName().startsWith(CACHE_DIR_PREFIX);
+    }
+
+    /**
+     * @param dir Directory.
+     * @return {@code True} if directory conforms cache group storage name 
pattern.
+     */
+    public static boolean cacheGroupDir(File dir) {
+        return dir.getName().startsWith(CACHE_GRP_DIR_PREFIX);
+    }
+
     /**
      * @param cacheDirName Cache directory name.
      * @return Store directory for given cache.
@@ -393,12 +425,29 @@ public class NodeFileTree extends SharedFileTree {
      * @param cacheOrGroupName Cache name.
      * @return The full cache directory name.
      */
-    private String cacheDirName(boolean isSharedGroup, String 
cacheOrGroupName) {
+    public static String cacheDirName(boolean isSharedGroup, String 
cacheOrGroupName) {
         return isSharedGroup
             ? CACHE_GRP_DIR_PREFIX + cacheOrGroupName
             : CACHE_DIR_PREFIX + cacheOrGroupName;
     }
 
+    /**
+     * @param dir Directory
+     * @return Cache name for directory, if it conforms cache storage pattern.
+     */
+    public static String cacheName(File dir) {
+        String name = dir.getName();
+
+        if (name.startsWith(CACHE_GRP_DIR_PREFIX))
+            return name.substring(CACHE_GRP_DIR_PREFIX.length());
+        else if (name.startsWith(CACHE_DIR_PREFIX))
+            return name.substring(CACHE_DIR_PREFIX.length());
+        else if (name.equals(MetaStorage.METASTORAGE_DIR_NAME))
+            return MetaStorage.METASTORAGE_CACHE_NAME;
+        else
+            throw new IgniteException("Directory doesn't match the cache or 
cache group prefix: " + dir);
+    }
+
     /**
      * Resolves directory specified by the given arguments.
      *
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
index cdc456fc093..946aa5fb8c9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
@@ -214,9 +214,9 @@ import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.isPersi
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_TEMPLATE;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirectories;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFile;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName;
+import static 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.cacheName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER;
 import static 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID;
 import static 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME;
@@ -664,7 +664,7 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
                 for (SnapshotMetadata m: readSnapshotMetadatas(name, null)) {
                     List<File> dirs = 
snapshotCacheDirectories(m.snapshotName(), null, m.folderName(), grpName -> 
true);
 
-                    Collection<String> cacheGrps = F.viewReadOnly(dirs, 
FilePageStoreManager::cacheGroupName);
+                    Collection<String> cacheGrps = F.viewReadOnly(dirs, 
NodeFileTree::cacheName);
 
                     views.add(new SnapshotView(m, cacheGrps));
                 }
@@ -3999,7 +3999,7 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
 
                 if (log.isInfoEnabled()) {
                     log.info("Partition file has been sent [part=" + 
part.getName() + ", pair=" + pair +
-                        ", grpName=" + cacheGroupName(new File(cacheDirName)) 
+ ", length=" + len + ']');
+                        ", grpName=" + cacheName(new File(cacheDirName)) + ", 
length=" + len + ']');
                 }
             }
             catch (TransmissionCancelledException e) {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
index 1d12b54e81f..8020151a315 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
@@ -79,9 +79,9 @@ import static 
org.apache.ignite.internal.processors.cache.persistence.file.FileP
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.FILE_SUFFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.ZIP_SUFFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirectories;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cachePartitionFiles;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.partId;
+import static 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.cacheName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.CreateDumpFutureTask.DUMP_FILE_EXT;
@@ -137,7 +137,7 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
         Map<Integer, File> grpDirs = new HashMap<>();
 
         for (File dir : cacheDirectories(new File(opCtx.snapshotDirectory(), 
databaseRelativePath(meta.folderName())), name -> true)) {
-            int grpId = CU.cacheId(cacheGroupName(dir));
+            int grpId = CU.cacheId(cacheName(dir));
 
             if (!grps.remove(grpId))
                 continue;
@@ -210,7 +210,7 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
                 snpMgr.snapshotExecutorService(),
                 partFiles,
                 part -> {
-                    String grpName = cacheGroupName(part.getParentFile());
+                    String grpName = cacheName(part.getParentFile());
                     int grpId = CU.cacheId(grpName);
                     int partId = partId(part.getName());
 
@@ -372,7 +372,7 @@ public class SnapshotPartitionsVerifyHandler implements 
SnapshotHandler<Map<Part
                 Collection<PartitionHashRecord> partitionHashRecords = 
U.doInParallel(
                     cctx.snapshotMgr().snapshotExecutorService(),
                     partFiles,
-                    part -> calculateDumpedPartitionHash(dump, 
cacheGroupName(part.getParentFile()), partId(part.getName()))
+                    part -> calculateDumpedPartitionHash(dump, 
cacheName(part.getParentFile()), partId(part.getName()))
                 );
 
                 return 
partitionHashRecords.stream().collect(Collectors.toMap(PartitionHashRecord::partitionKey,
 r -> r));
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
index 2401defe2ad..fff94c4644a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
@@ -100,9 +100,8 @@ import org.jetbrains.annotations.Nullable;
 
 import static java.util.Optional.ofNullable;
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.partId;
+import static 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.cacheName;
 import static 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME;
 import static 
org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath;
@@ -462,7 +461,7 @@ public class SnapshotRestoreProcess {
             return true;
 
         for (File grpDir : opCtx.dirs) {
-            String locGrpName = FilePageStoreManager.cacheGroupName(grpDir);
+            String locGrpName = cacheName(grpDir);
 
             if (grpName != null) {
                 if (cacheName.equals(locGrpName))
@@ -731,7 +730,7 @@ public class SnapshotRestoreProcess {
 
         String cacheGrpName = 
tmpCacheDir.getName().substring(TMP_CACHE_DIR_PREFIX.length());
 
-        return CU.cacheId(cacheGroupName(new File(tmpCacheDir.getParentFile(), 
cacheGrpName)));
+        return CU.cacheId(cacheName(new File(tmpCacheDir.getParentFile(), 
cacheGrpName)));
     }
 
     /**
@@ -769,12 +768,12 @@ public class SnapshotRestoreProcess {
         for (SnapshotMetadata meta : metas) {
             for (File snpCacheDir : 
cctx.snapshotMgr().snapshotCacheDirectories(req.snapshotName(), 
req.snapshotPath(), meta.folderName(),
                 name -> !METASTORAGE_CACHE_NAME.equals(name))) {
-                String grpName = 
FilePageStoreManager.cacheGroupName(snpCacheDir);
+                String grpName = cacheName(snpCacheDir);
 
                 if (!F.isEmpty(req.groups()) && 
!req.groups().contains(grpName))
                     continue;
 
-                File cacheDir = 
ft.cacheStorage(snpCacheDir.getName().startsWith(CACHE_GRP_DIR_PREFIX), 
grpName);
+                File cacheDir = 
ft.cacheStorage(NodeFileTree.cacheGroupDir(snpCacheDir), grpName);
 
                 if (cacheDir.exists()) {
                     if (!cacheDir.isDirectory()) {
@@ -948,7 +947,7 @@ public class SnapshotRestoreProcess {
                 log.info("Starting snapshot preload operation to restore cache 
groups " +
                     "[reqId=" + reqId +
                     ", snapshot=" + opCtx0.snpName +
-                    ", caches=" + F.transform(opCtx0.dirs, 
FilePageStoreManager::cacheGroupName) + ']');
+                    ", caches=" + F.transform(opCtx0.dirs, 
NodeFileTree::cacheName) + ']');
             }
 
             File snpDir = snpMgr.snapshotLocalDir(opCtx0.snpName, 
opCtx0.snpPath);
@@ -992,7 +991,7 @@ public class SnapshotRestoreProcess {
 
             // First preload everything from the local node.
             for (File dir : opCtx0.dirs) {
-                String cacheOrGrpName = cacheGroupName(dir);
+                String cacheOrGrpName = cacheName(dir);
                 int grpId = CU.cacheId(cacheOrGrpName);
 
                 if (log.isInfoEnabled())
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
index 1267e18bf88..34e2ed01d4d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
@@ -58,6 +58,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow;
 import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId;
 import 
org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractCreateSnapshotFutureTask;
 import 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager;
@@ -75,8 +76,6 @@ import org.jetbrains.annotations.Nullable;
 
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
 import static 
org.apache.ignite.internal.processors.cache.GridLocalConfigManager.cacheDataFilename;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.DUMP_LOCK;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.Dump.dumpPartFileName;
 import static org.apache.ignite.internal.util.IgniteUtils.toLong;
@@ -717,7 +716,7 @@ public class CreateDumpFutureTask extends 
AbstractCreateSnapshotFutureTask imple
     private File groupDirectory(CacheGroupContext grpCtx) throws 
IgniteCheckedException {
         return new File(
             IgniteSnapshotManager.nodeDumpDirectory(dumpDir, cctx),
-            (grpCtx.caches().size() > 1 ? CACHE_GRP_DIR_PREFIX : 
CACHE_DIR_PREFIX) + grpCtx.cacheOrGroupName()
+            NodeFileTree.cacheDirName(grpCtx.caches().size() > 1, 
grpCtx.cacheOrGroupName())
         );
     }
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/Dump.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/Dump.java
index fb715571cc2..0afb5819112 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/Dump.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/Dump.java
@@ -64,8 +64,6 @@ import org.jetbrains.annotations.Nullable;
 
 import static java.nio.file.StandardOpenOption.READ;
 import static 
org.apache.ignite.internal.processors.cache.GridLocalConfigManager.readCacheData;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.ZIP_SUFFIX;
@@ -371,18 +369,9 @@ public class Dump implements AutoCloseable {
 
         assert nodeDir.exists() && nodeDir.isDirectory();
 
-        File[] grpDirs = nodeDir.listFiles(f -> {
-            if (!f.isDirectory()
-                || (!f.getName().startsWith(CACHE_DIR_PREFIX)
-                    && !f.getName().startsWith(CACHE_GRP_DIR_PREFIX)))
-                return false;
-
-            String grpName = f.getName().startsWith(CACHE_DIR_PREFIX)
-                ? f.getName().replaceFirst(CACHE_DIR_PREFIX, "")
-                : f.getName().replaceFirst(CACHE_GRP_DIR_PREFIX, "");
-
-            return grpId == CU.cacheId(grpName);
-        });
+        File[] grpDirs = nodeDir.listFiles(f -> f.isDirectory()
+            && NodeFileTree.CACHE_DIR_FILTER.test(f)
+            && grpId == CU.cacheId(NodeFileTree.cacheName(f)));
 
         if (grpDirs.length != 1)
             throw new IgniteException("Wrong number of group directories: " + 
grpDirs.length);
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyUtility.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyUtility.java
index 367733b18df..f0a31b8360a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyUtility.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyUtility.java
@@ -60,7 +60,7 @@ import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_AUX;
 import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
 import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
 import static 
org.apache.ignite.internal.processors.cache.CacheObject.TYPE_BINARY;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName;
+import static 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.cacheName;
 
 /**
  * Utility class for idle verify command.
@@ -135,7 +135,7 @@ public class IdleVerifyUtility {
         }
         catch (Throwable e) {
             String msg0 = CRC_CHECK_ERR_MSG + " [partId=" + partId +
-                ", grpName=" + (pageStore == null ? "" : cacheGroupName(new 
File(pageStore.getFileAbsolutePath()).getParentFile())) +
+                ", grpName=" + (pageStore == null ? "" : cacheName(new 
File(pageStore.getFileAbsolutePath()).getParentFile())) +
                 ", part=" + (pageStore == null ? "" : 
pageStore.getFileAbsolutePath()) + ']';
 
             throw new IgniteException(msg0, e);
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDefragmentationTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDefragmentationTest.java
index c8d6d1ad5c3..4200a71ab09 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDefragmentationTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDefragmentationTest.java
@@ -62,6 +62,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.defragmentation.D
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.maintenance.MaintenanceRegistry;
@@ -231,7 +232,7 @@ public class IgnitePdsDefragmentationTest extends 
GridCommonAbstractTest {
 
         stopGrid(0);
 
-        File workDir = resolveCacheWorkDir(ig);
+        File workDir = 
ig.context().pdsFolderResolver().fileTree().cacheStorage(true, GRP_NAME);
 
         long[] oldPartLen = partitionSizes(workDir);
 
@@ -298,18 +299,6 @@ public class IgnitePdsDefragmentationTest extends 
GridCommonAbstractTest {
         }).toArray();
     }
 
-    /**
-     * @return Working directory for cache group {@link 
IgnitePdsDefragmentationTest#GRP_NAME}.
-     * @throws IgniteCheckedException If failed for some reason, like if it's 
a file instead of directory.
-     */
-    private File resolveCacheWorkDir(IgniteEx ig) throws 
IgniteCheckedException {
-        File dbWorkDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), 
DFLT_STORE_DIR, false);
-
-        File nodeWorkDir = new File(dbWorkDir, U.maskForFileName(ig.name()));
-
-        return new File(nodeWorkDir, FilePageStoreManager.CACHE_GRP_DIR_PREFIX 
+ GRP_NAME);
-    }
-
     /**
      * Force checkpoint and wait for it so all partitions will be in their 
final state after restart if no more data is
      * uploaded.
@@ -472,7 +461,7 @@ public class IgnitePdsDefragmentationTest extends 
GridCommonAbstractTest {
 
         stopGrid(0);
 
-        File workDir = resolveCacheWorkDir(ig);
+        File workDir = 
ig.context().pdsFolderResolver().fileTree().cacheStorage(true, GRP_NAME);
 
         //Defragmentation should fail when node starts.
         startAndAwaitNodeFail(workDir);
@@ -588,7 +577,7 @@ public class IgnitePdsDefragmentationTest extends 
GridCommonAbstractTest {
             }
 
             @Override public FileVisitResult visitFile(Path path, 
BasicFileAttributes basicFileAttributes) throws IOException {
-                if (path.toString().contains("cacheGroup-group")) {
+                if (path.toString().contains(NodeFileTree.cacheDirName(true, 
"group"))) {
                     File file = path.toFile();
 
                     if (file.getName().contains("part-dfrg-"))
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PagesPossibleCorruptionDiagnosticTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PagesPossibleCorruptionDiagnosticTest.java
index 5099290f73c..08554227c4f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PagesPossibleCorruptionDiagnosticTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PagesPossibleCorruptionDiagnosticTest.java
@@ -50,7 +50,6 @@ import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_SKIP_CRC;
 import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
 import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId;
 import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_TEMPLATE;
 import static 
org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIOV2.PART_META_REUSE_LIST_ROOT_OFF;
 
@@ -117,7 +116,7 @@ public class PagesPossibleCorruptionDiagnosticTest extends 
GridCommonAbstractTes
      * @throws IgniteCheckedException If failed.
      */
     private FilePageStore filePageStore(IgniteEx ignite, int partId) throws 
IgniteCheckedException {
-        File cacheWorkDir = new 
File(ignite.context().pdsFolderResolver().fileTree().nodeStorage(), 
CACHE_DIR_PREFIX + DEFAULT_CACHE_NAME);
+        File cacheWorkDir = 
ignite.context().pdsFolderResolver().fileTree().cacheStorage(false, 
DEFAULT_CACHE_NAME);
 
         File partFile = new File(cacheWorkDir, format(PART_FILE_TEMPLATE, 
partId));
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointFreeListTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointFreeListTest.java
index a693295c73b..084efc3ba1e 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointFreeListTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/CheckpointFreeListTest.java
@@ -19,7 +19,6 @@ package 
org.apache.ignite.internal.processors.cache.persistence.db.checkpoint;
 
 import java.io.File;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -70,8 +69,6 @@ import 
org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Test;
 
 import static java.util.Objects.requireNonNull;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
 import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 
@@ -264,11 +261,7 @@ public class CheckpointFreeListTest extends 
GridCommonAbstractTest {
 
         forceCheckpoint();
 
-        Path cacheFolder = Paths.get(U.defaultWorkDirectory(),
-            DFLT_STORE_DIR,
-            ignite0.name().replaceAll("\\.", "_"),
-            CACHE_DIR_PREFIX + CACHE_NAME
-        );
+        Path cacheFolder = 
ignite0.context().pdsFolderResolver().fileTree().cacheStorage(false, 
CACHE_NAME).toPath();
 
         Optional<Long> totalPartSizeBeforeStop = 
totalPartitionsSize(cacheFolder);
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java
index f833c7c5c82..e9da8b75e4f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java
@@ -206,7 +206,7 @@ public class WalCompactionTest extends 
GridCommonAbstractTest {
         assertNotNull(cpMarkers);
         assertTrue(cpMarkers.length > 0);
 
-        File cacheDir = new File(ft.nodeStorage(), "cache-" + CACHE_NAME);
+        File cacheDir = ft.cacheStorage(false, CACHE_NAME);
         File[] lfsFiles = cacheDir.listFiles();
 
         assertNotNull(lfsFiles);
@@ -500,7 +500,7 @@ public class WalCompactionTest extends 
GridCommonAbstractTest {
         assertNotNull(cpMarkers);
         assertTrue(cpMarkers.length > 0);
 
-        File cacheDir = new File(ft.nodeStorage(), "cache-" + CACHE_NAME);
+        File cacheDir = ft.cacheStorage(false, CACHE_NAME);
         File[] lfsFiles = cacheDir.listFiles();
 
         assertNotNull(lfsFiles);
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
index f7a9e5f5a07..a4640d93112 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
@@ -77,6 +77,7 @@ import 
org.apache.ignite.internal.pagemem.wal.record.WALRecord;
 import org.apache.ignite.internal.processors.cache.CacheGroupContext;
 import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.filename.SharedFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId;
 import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer;
@@ -113,8 +114,6 @@ import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static org.apache.ignite.cluster.ClusterState.INACTIVE;
 import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE;
 import static org.apache.ignite.events.EventType.EVTS_CLUSTER_SNAPSHOT;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.FILE_SUFFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_DIR_NAME;
@@ -641,9 +640,7 @@ public abstract class AbstractSnapshotSelfTest extends 
GridCommonAbstractTest {
             File[] cacheDirs = nodeSnapDir.listFiles(f -> f.isDirectory() && 
!f.getName().equals(METASTORAGE_DIR_NAME));
 
             for (File cacheDir : cacheDirs) {
-                String name = 
cacheDir.getName().startsWith(CACHE_GRP_DIR_PREFIX)
-                    ? 
cacheDir.getName().substring(CACHE_GRP_DIR_PREFIX.length())
-                    : cacheDir.getName().substring(CACHE_DIR_PREFIX.length());
+                String name = NodeFileTree.cacheName(cacheDir);
 
                 Map<Integer, Integer> cacheParts = 
cachesParts.computeIfAbsent(name, k -> new HashMap<>());
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotDeltaTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotDeltaTest.java
index c79f8b4b6e9..f1e116bef55 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotDeltaTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotDeltaTest.java
@@ -36,6 +36,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
@@ -46,7 +47,6 @@ import org.junit.runners.Parameterized;
 
 import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_SNAPSHOT_SEQUENTIAL_WRITE;
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.DeltaSortedIterator.DELTA_SORT_BATCH_SIZE;
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.partDeltaIndexFile;
 import static org.junit.Assert.assertArrayEquals;
@@ -104,7 +104,7 @@ public class IgniteClusterSnapshotDeltaTest extends 
AbstractSnapshotSelfTest {
         CacheConfiguration<Integer, byte[]> ccfg = new 
CacheConfiguration<Integer, byte[]>(DEFAULT_CACHE_NAME)
             .setAffinity(new RendezvousAffinityFunction(false, partCnt));
 
-        String cacheDir = CACHE_DIR_PREFIX + DEFAULT_CACHE_NAME;
+        String cacheDir = NodeFileTree.cacheDirName(false, DEFAULT_CACHE_NAME);
 
         IgniteEx srv = startGridsWithCache(1, keys, (k) -> expPayload, ccfg);
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
index 6b27adde607..abb374e1818 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java
@@ -57,6 +57,7 @@ import 
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
 import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType;
 import org.apache.ignite.internal.util.distributed.SingleNodeMessage;
 import org.apache.ignite.internal.util.typedef.F;
@@ -73,7 +74,6 @@ import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static 
org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_FAILED;
 import static 
org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_FINISHED;
 import static 
org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.FILE_SUFFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName;
@@ -670,7 +670,7 @@ public class IgniteClusterSnapshotRestoreSelfTest extends 
IgniteClusterSnapshotR
         spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage &&
             ((SingleNodeMessage<?>)msg).type() == 
RESTORE_CACHE_GROUP_SNAPSHOT_PRELOAD.ordinal());
 
-        String failingFilePath = Paths.get(CACHE_DIR_PREFIX + 
DEFAULT_CACHE_NAME,
+        String failingFilePath = Paths.get(NodeFileTree.cacheDirName(false, 
DEFAULT_CACHE_NAME),
             PART_FILE_PREFIX + (dfltCacheCfg.getAffinity().partitions() / 2) + 
FILE_SUFFIX).toString();
 
         grid(2).context().cache().context().snapshotMgr().ioFactory(
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
index 7e62a7eb331..b90aa7ee89e 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
@@ -115,7 +115,6 @@ import static 
org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED;
 import static org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_STARTED;
 import static 
org.apache.ignite.internal.encryption.AbstractEncryptionTest.MASTER_KEY_NAME_2;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.ZIP_SUFFIX;
 import static 
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER;
@@ -425,10 +424,9 @@ public class IgniteCacheDumpSelf2Test extends 
GridCommonAbstractTest {
             assertNotNull(nodes);
             assertEquals(1, nodes.size());
 
-            File cacheDumpDir = new File(
-                dump.dumpDirectory(),
-                DB_DEFAULT_FOLDER + File.separator + nodes.get(0) + 
File.separator + CACHE_DIR_PREFIX + DEFAULT_CACHE_NAME
-            );
+            NodeFileTree ft = dump.fileTrees().get(0);
+
+            File cacheDumpDir = ft.cacheStorage(false, DEFAULT_CACHE_NAME);
 
             assertTrue(cacheDumpDir.exists());
 
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsIndexingDefragmentationTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsIndexingDefragmentationTest.java
index 3ed5c867983..0eccdb63963 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsIndexingDefragmentationTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsIndexingDefragmentationTest.java
@@ -42,14 +42,13 @@ import 
org.apache.ignite.internal.processors.cache.GridCacheContext;
 import 
org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.defragmentation.DefragmentationFileUtils;
 import 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.query.schema.IndexRebuildCancelToken;
 import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 import org.junit.Test;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 
 /**
  * Defragmentation tests with enabled ignite-indexing.
@@ -118,6 +117,8 @@ public class IgnitePdsIndexingDefragmentationTest extends 
IgnitePdsDefragmentati
 
         ig.cluster().state(ClusterState.ACTIVE);
 
+        NodeFileTree ft = ig.context().pdsFolderResolver().fileTree();
+
         fillCache(keyMapper, ig.cache(DEFAULT_CACHE_NAME));
 
         forceCheckpoint(ig);
@@ -126,25 +127,23 @@ public class IgnitePdsIndexingDefragmentationTest extends 
IgnitePdsDefragmentati
 
         stopGrid(0);
 
-        File dbWorkDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), 
DFLT_STORE_DIR, false);
-        File nodeWorkDir = new File(dbWorkDir, U.maskForFileName(ig.name()));
-        File workDir = new File(nodeWorkDir, 
FilePageStoreManager.CACHE_GRP_DIR_PREFIX + GRP_NAME);
+        File cacheStorage = ft.cacheStorage(true, GRP_NAME);
 
-        long oldIdxFileLen = new File(workDir, 
FilePageStoreManager.INDEX_FILE_NAME).length();
+        long oldIdxFileLen = new File(cacheStorage, 
FilePageStoreManager.INDEX_FILE_NAME).length();
 
         startGrid(0);
 
         waitForDefragmentation(0);
 
-        long newIdxFileLen = new File(workDir, 
FilePageStoreManager.INDEX_FILE_NAME).length();
+        long newIdxFileLen = new File(cacheStorage, 
FilePageStoreManager.INDEX_FILE_NAME).length();
 
         assertTrue(
             "newIdxFileLen=" + newIdxFileLen + ", oldIdxFileLen=" + 
oldIdxFileLen,
             newIdxFileLen <= oldIdxFileLen
         );
 
-        File completionMarkerFile = 
DefragmentationFileUtils.defragmentationCompletionMarkerFile(workDir);
-        assertTrue(Arrays.toString(workDir.listFiles()), 
completionMarkerFile.exists());
+        File completionMarkerFile = 
DefragmentationFileUtils.defragmentationCompletionMarkerFile(cacheStorage);
+        assertTrue(Arrays.toString(cacheStorage.listFiles()), 
completionMarkerFile.exists());
 
         stopGrid(0);
 
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteCacheGroupsWithRestartsTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteCacheGroupsWithRestartsTest.java
index 3b22b27d39f..e80ce89c67a 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteCacheGroupsWithRestartsTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteCacheGroupsWithRestartsTest.java
@@ -29,7 +29,6 @@ import javax.cache.configuration.Factory;
 import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
@@ -61,7 +60,6 @@ import org.junit.Test;
 
 import static org.apache.ignite.cluster.ClusterState.ACTIVE;
 import static 
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 
 /**
  * Testing corner cases in cache group functionality: -stopping cache in 
shared group and immediate node leaving;
@@ -204,24 +202,13 @@ public class IgniteCacheGroupsWithRestartsTest extends 
GridCommonAbstractTest {
                     contains("Joining node has caches with data which are not 
presented on cluster")));
         }
 
-        removeCacheDir(getTestIgniteInstanceName(2), "cacheGroup-group");
+        U.delete(nodeFileTree(getTestIgniteInstanceName(2).replace(".", 
"_")).cacheStorage(true, "group"));
 
         IgniteEx node2 = startGrid(2);
 
         assertEquals(3, node2.cluster().nodes().size());
     }
 
-    /**
-     * @param instanceName Instance name.
-     * @param cacheGroup Cache group.
-     */
-    private void removeCacheDir(String instanceName, String cacheGroup) throws 
IgniteCheckedException {
-        String dn2DirName = instanceName.replace(".", "_");
-
-        U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(),
-            DFLT_STORE_DIR + "/" + dn2DirName + "/" + cacheGroup, true));
-    }
-
     /**
      * @throws Exception If failed.
      */
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
index 29f52038440..3922635c984 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java
@@ -34,7 +34,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Random;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadLocalRandom;
@@ -91,6 +90,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabase
 import 
org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry;
 import 
org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntryType;
 import 
org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointMarkersStorage;
+import 
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
 import 
org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage;
 import 
org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx;
 import 
org.apache.ignite.internal.processors.cache.persistence.tree.io.CompactablePageIO;
@@ -135,8 +135,6 @@ import static 
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_CHEC
 import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME;
 import static 
org.apache.ignite.internal.processors.cache.persistence.CheckpointState.FINISHED;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
-import static 
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.genNewStyleSubfolderName;
 
 /**
  *
@@ -748,13 +746,15 @@ public class IgniteWalRecoveryTest extends 
GridCommonAbstractTest {
         for (int i = 0; i < 100; i++)
             cache.put(i, new IndexedObject(i));
 
-        final Object consistentId = 
ignite.cluster().localNode().consistentId();
+        NodeFileTree ft = ignite.context().pdsFolderResolver().fileTree();
 
         stopGrid(1);
 
-        final File cacheDir = cacheDir(CACHE_NAME, consistentId.toString());
+        final File cacheDir = ft.cacheStorage(false, CACHE_NAME);
 
-        renamed = cacheDir.renameTo(new File(cacheDir.getParent(), "cache-" + 
RENAMED_CACHE_NAME));
+        assertTrue(cacheDir.exists());
+
+        renamed = cacheDir.renameTo(ft.cacheStorage(false, 
RENAMED_CACHE_NAME));
 
         assert renamed;
 
@@ -768,30 +768,6 @@ public class IgniteWalRecoveryTest extends 
GridCommonAbstractTest {
             assertEquals(new IndexedObject(i), cache.get(i));
     }
 
-    /**
-     * @param cacheName Cache name.
-     * @param consId Consistent ID.
-     * @return Cache dir.
-     * @throws IgniteCheckedException If fail.
-     */
-    private File cacheDir(final String cacheName, final String consId) throws 
IgniteCheckedException {
-        final String subfolderName = genNewStyleSubfolderName(0, 
UUID.fromString(consId));
-
-        final File dbDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), 
DFLT_STORE_DIR, false);
-
-        assert dbDir.exists();
-
-        final File consIdDir = new File(dbDir.getAbsolutePath(), 
subfolderName);
-
-        assert consIdDir.exists();
-
-        final File cacheDir = new File(consIdDir.getAbsolutePath(), "cache-" + 
cacheName);
-
-        assert cacheDir.exists();
-
-        return cacheDir;
-    }
-
     /**
      * @throws Exception if failed.
      */
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/WalDisabledDuringIndexRecreateTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/WalDisabledDuringIndexRecreateTest.java
index 95fd17799c4..c81b3a262e0 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/WalDisabledDuringIndexRecreateTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/WalDisabledDuringIndexRecreateTest.java
@@ -65,9 +65,6 @@ import static 
org.apache.ignite.configuration.DataStorageConfiguration.UNLIMITED
 import static 
org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
 import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId;
 import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_GRP_DIR_PREFIX;
-import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 import static 
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME;
 import static 
org.apache.ignite.internal.processors.query.schema.management.SortedIndexDescriptorFactory.H2_TREE;
 
@@ -296,14 +293,12 @@ public class WalDisabledDuringIndexRecreateTest extends 
GridCommonAbstractTest {
     }
 
     /** */
-    private File checkIdxFile() throws IgniteCheckedException {
-        String dirName = cacheGrps ? (CACHE_GRP_DIR_PREFIX + cacheGroupName()) 
: (CACHE_DIR_PREFIX + cacheName());
-
-        File idxFile = new File(U.resolveWorkDirectory(
-            U.defaultWorkDirectory(),
-            DFLT_STORE_DIR + File.separatorChar + grid(0).name().replace(".", 
"_") + File.separatorChar + dirName,
-            false
-        ), INDEX_FILE_NAME);
+    private File checkIdxFile() {
+        NodeFileTree ft = grid(0).context().pdsFolderResolver().fileTree();
+
+        File idxFile = new File(
+            ft.cacheStorage(cacheGrps, cacheGrps ? cacheGroupName() : 
cacheName()),
+            INDEX_FILE_NAME);
 
         assertTrue("Index file not found", idxFile.exists());
 

Reply via email to