diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java index 59c00cd32bc91..be3496844aefe 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java @@ -69,6 +69,8 @@ public class AbstractBasicIntegrationTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + cleanPersistenceDir(); + startGrids(nodeCount()); client = startClientGrid("client"); diff --git a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java index 23640957d91d0..ebbda978bf288 100644 --- a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java +++ b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java @@ -32,7 +32,6 @@ import org.apache.ignite.cluster.ClusterState; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgnitePredicate; @@ -343,11 +342,7 @@ private Ignite prepareGridForTest() throws Exception { * Get index partition file for specific node and cache. */ private File indexPartition(Ignite ig, String groupName) { - IgniteEx ig0 = (IgniteEx)ig; - - FilePageStoreManager pageStoreMgr = ((FilePageStoreManager)ig0.context().cache().context().pageStore()); - - return new File(pageStoreMgr.cacheWorkDir(true, groupName), INDEX_FILE_NAME); + return new File(((IgniteEx)ig).context().pdsFolderResolver().fileTree().cacheStorage(true, groupName), INDEX_FILE_NAME); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cdc/CdcMain.java b/modules/core/src/main/java/org/apache/ignite/internal/cdc/CdcMain.java index f9b3d3f94f5f2..d6c31b425380a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cdc/CdcMain.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cdc/CdcMain.java @@ -453,7 +453,7 @@ private CdcFileLockHolder lockPds() throws IgniteCheckedException { CdcFileLockHolder lock = settings.getLockedFileLockHolder(); if (lock == null) { - File consIdDir = settings.persistentStoreNodePath(); + File consIdDir = ft.nodeStorage(); lock = tryLock(consIdDir); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceTask.java b/modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceTask.java index 95ec61ac20c15..4f6a8dee118a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceTask.java @@ -44,7 +44,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.persistence.CheckCorruptedCacheStoresCleanAction; import org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction; -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.task.GridInternal; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; @@ -57,7 +57,6 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME; -import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirName; /** */ @GridInternal @@ -78,6 +77,9 @@ private static class PersistenceJob extends VisorJob allCacheDirs = cacheProc.cacheDescriptors() .values() .stream() - .map(desc -> cacheDirName(desc.cacheConfiguration())) + .map(desc -> ft.cacheDirName(desc.cacheConfiguration())) .distinct() .collect(Collectors.toList()); - return backupCaches(workDir, allCacheDirs); + return backupCaches(allCacheDirs); } /** */ - private PersistenceTaskResult backupCaches(File workDir, List cacheDirs) { + private PersistenceTaskResult backupCaches(List cacheDirs) { PersistenceTaskResult res = new PersistenceTaskResult(true); List backupCompletedCaches = new ArrayList<>(); @@ -144,13 +146,13 @@ private PersistenceTaskResult backupCaches(File workDir, List cacheDirs) for (String dir : cacheDirs) { String backupDirName = BACKUP_FOLDER_PREFIX + dir; - File backupDir = new File(workDir, backupDirName); + File backupDir = new File(ft.nodeStorage(), backupDirName); if (!backupDir.exists()) { try { U.ensureDirectory(backupDir, backupDirName, null); - copyCacheFiles(workDir.toPath().resolve(dir).toFile(), backupDir); + copyCacheFiles(ft.nodeStorage().toPath().resolve(dir).toFile(), backupDir); backupCompletedCaches.add(backupDirName); } @@ -228,7 +230,7 @@ private PersistenceTaskResult cleanCaches( try { pageStore.cleanupPersistentSpace(cacheDescr.cacheConfiguration()); - cleanedCaches.add(cacheDirName(cacheDescr.cacheConfiguration())); + cleanedCaches.add(ft.cacheDirName(cacheDescr.cacheConfiguration())); } catch (IgniteCheckedException e) { failedToCleanCaches.add(name); @@ -268,7 +270,7 @@ private PersistenceTaskResult cleanAll(GridCacheProcessor cacheProc, Maintenance List allCacheDirs = cacheProc.cacheDescriptors() .values() .stream() - .map(desc -> cacheDirName(desc.cacheConfiguration())) + .map(desc -> ft.cacheDirName(desc.cacheConfiguration())) .collect(Collectors.toList()); try { @@ -392,7 +394,7 @@ private List cacheDirectoriesFromCacheNames(String[] cacheNames) { .filter(s -> CU.isPersistentCache(cacheProc.cacheDescriptor(s).cacheConfiguration(), dsCfg)) .map(s -> cacheProc.cacheDescriptor(s).cacheConfiguration()) - .map(FilePageStoreManager::cacheDirName) + .map(ft::cacheDirName) .distinct() .collect(Collectors.toList()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java index 6f8a9ad648fa3..412e1a20b128d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java @@ -273,7 +273,7 @@ private IgniteInternalFuture persistCacheConfigurations(List for (StoredCacheData data : cacheConfigsToPersist) { try { FilePageStoreManager.checkAndInitCacheWorkDir( - cctx.cache().configManager().cacheWorkDir(data.config()), + cctx.kernalContext().pdsFolderResolver().fileTree().cacheStorage(data.config()), log ); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java index 2894875c7a834..d405f6c000de6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java @@ -92,7 +92,6 @@ import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.CACHE_PROC; import static org.apache.ignite.internal.processors.cache.GridCacheProcessor.CLUSTER_READ_ONLY_MODE_ERROR_MSG_FORMAT; import static org.apache.ignite.internal.processors.cache.GridLocalConfigManager.validateIncomingConfiguration; -import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirName; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNP_IN_PROGRESS_ERR_MSG; /** @@ -1202,7 +1201,7 @@ private boolean containsInvalidFileNameChars(CacheConfiguration ccfg) { if (!CU.isPersistentCache(ccfg, ctx.config().getDataStorageConfiguration())) return false; - String expDir = cacheDirName(ccfg); + String expDir = ctx.pdsFolderResolver().fileTree().cacheDirName(ccfg); try { return !expDir.equals(Paths.get(expDir).toFile().getName()); 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 005a93c7463d1..0e3ffb8219b93 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 @@ -58,7 +58,7 @@ import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; -import org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings; +import org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; @@ -100,8 +100,8 @@ public class GridLocalConfigManager { /** Cache processor. */ private final GridCacheProcessor cacheProcessor; - /** Absolute directory for file page store. Includes consistent id based folder. */ - private final File storeWorkDir; + /** Node file tree. */ + private final NodeFileTree ft; /** Marshaller. */ private final Marshaller marshaller; @@ -124,16 +124,10 @@ public GridLocalConfigManager( ctx = kernalCtx; log = ctx.log(getClass()); marshaller = ctx.marshallerContext().jdkMarshaller(); + ft = ctx.pdsFolderResolver().fileTree(); - PdsFolderSettings folderSettings = ctx.pdsFolderResolver().resolveFolders(); - - if (!ctx.clientNode() && folderSettings.persistentStoreRootPath() != null) { - storeWorkDir = folderSettings.persistentStoreNodePath(); - - U.ensureDirectory(storeWorkDir, "page store work directory", log); - } - else - storeWorkDir = null; + if (!ctx.clientNode() && ft.nodeStorage() != null) + U.ensureDirectory(ft.nodeStorage(), "page store work directory", log); } /** @@ -148,7 +142,7 @@ public void readConfigurationFiles( try { for (CacheConfiguration ccfg : ccfgs) { - File cacheDir = cacheWorkDir(ccfg); + File cacheDir = ft.cacheStorage(ccfg); if (!cacheDir.exists()) continue; @@ -175,7 +169,7 @@ public Map readCacheConfigurations() throws IgniteCheck if (ctx.clientNode()) return Collections.emptyMap(); - File[] files = storeWorkDir.listFiles(); + File[] files = ft.nodeStorage().listFiles(); if (files == null) return Collections.emptyMap(); @@ -293,7 +287,7 @@ public void saveCacheConfiguration( if (!CU.storeCacheConfig(cacheProcessor.context(), ccfg)) return; - File cacheWorkDir = cacheWorkDir(ccfg); + File cacheWorkDir = ft.cacheStorage(ccfg); FilePageStoreManager.checkAndInitCacheWorkDir(cacheWorkDir, log); @@ -426,7 +420,7 @@ public void removeConfigurationChangeListener(BiConsumer lsnr) { * @throws IgniteCheckedException If fails. */ public void removeCacheGroupConfigurationData(CacheGroupContext ctx) throws IgniteCheckedException { - File cacheGrpDir = cacheWorkDir(ctx.sharedGroup(), ctx.cacheOrGroupName()); + File cacheGrpDir = ft.cacheStorage(ctx.config()); if (cacheGrpDir != null && cacheGrpDir.exists()) { DirectoryStream.Filter cacheCfgFileFilter = new DirectoryStream.Filter() { @@ -537,9 +531,7 @@ private boolean inMemoryCdcCache(CacheConfiguration cfg) { * @return Cache configuration file with respect to {@link CacheConfiguration#getGroupName} value. */ public File cacheConfigurationFile(CacheConfiguration ccfg) { - File cacheWorkDir = cacheWorkDir(ccfg); - - return new File(cacheWorkDir, cacheDataFilename(ccfg)); + return new File(ft.cacheStorage(ccfg), cacheDataFilename(ccfg)); } /** @return Name of cache data filename. */ @@ -547,23 +539,6 @@ public static String cacheDataFilename(CacheConfiguration ccfg) { return ccfg.getGroupName() == null ? CACHE_DATA_FILENAME : (ccfg.getName() + CACHE_DATA_FILENAME); } - /** - * @param ccfg Cache configuration. - * @return Store dir for given cache. - */ - public File cacheWorkDir(CacheConfiguration ccfg) { - return FilePageStoreManager.cacheWorkDir(storeWorkDir, FilePageStoreManager.cacheDirName(ccfg)); - } - - /** - * @param isSharedGroup {@code True} if cache is sharing the same `underlying` cache. - * @param cacheOrGroupName Cache name. - * @return Store directory for given cache. - */ - public File cacheWorkDir(boolean isSharedGroup, String cacheOrGroupName) { - return FilePageStoreManager.cacheWorkDir(storeWorkDir, FilePageStoreManager.cacheDirName(isSharedGroup, cacheOrGroupName)); - } - /** * @return {@code True} if need locally start all existing caches on client node start. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/defragmentation/CachePartitionDefragmentationManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/defragmentation/CachePartitionDefragmentationManager.java index 21b0947418576..6e589b1f71859 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/defragmentation/CachePartitionDefragmentationManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/defragmentation/CachePartitionDefragmentationManager.java @@ -58,6 +58,7 @@ import org.apache.ignite.internal.processors.cache.persistence.checkpoint.LightweightCheckpointManager; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.file.FileVersionCheckingFactory; +import org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree; import org.apache.ignite.internal.processors.cache.persistence.freelist.AbstractFreeList; import org.apache.ignite.internal.processors.cache.persistence.freelist.SimpleDataRow; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx; @@ -290,10 +291,12 @@ public void executeDefragmentation() throws IgniteCheckedException { IgniteInternalFuture idxDfrgFut = null; DataPageEvictionMode prevPageEvictionMode = null; + NodeFileTree ft = sharedCtx.kernalContext().pdsFolderResolver().fileTree(); + for (CacheGroupContext oldGrpCtx : cacheGrpCtxsForDefragmentation) { int grpId = oldGrpCtx.groupId(); - File workDir = filePageStoreMgr.cacheWorkDir(oldGrpCtx.sharedGroup(), oldGrpCtx.cacheOrGroupName()); + File workDir = ft.cacheStorage(oldGrpCtx.config()); List oldCacheDataStores = oldStores.get(grpId); 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 dd0c0cbe59af4..2bab7c563f138 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 @@ -247,7 +247,7 @@ public FilePageStoreManager(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void cleanupPersistentSpace(CacheConfiguration cacheConfiguration) throws IgniteCheckedException { try { - File cacheWorkDir = cacheWorkDir(cacheConfiguration); + File cacheWorkDir = ft.cacheStorage(cacheConfiguration); if (!cacheWorkDir.exists()) return; @@ -368,7 +368,7 @@ public FilePageStoreManager(GridKernalContext ctx) { new MaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME, "Corrupted cache groups found", cacheCfgs.stream() - .map(ccfg -> cacheWorkDir(ccfg).getName()) + .map(ccfg -> ft.cacheStorage(ccfg).getName()) .collect(Collectors.joining(File.separator))) ); } @@ -403,7 +403,7 @@ private List findCacheGroupsWithDisabledWal() { boolean globalEnabled = cctx.database().walEnabled(grpDescId, false); if (!locEnabled || !globalEnabled) { - File dir = cacheWorkDir(desc.config()); + File dir = ft.cacheStorage(desc.config()); if (Arrays.stream( dir.listFiles()).anyMatch(f -> !f.getName().equals(CACHE_DATA_FILENAME))) { @@ -540,13 +540,6 @@ private List findCacheGroupsWithDisabledWal() { return store.pageOffset(pageId); } - /** - * - */ - public Path getPath(boolean isSharedGroup, String cacheOrGroupName, int partId) { - return getPartitionFilePath(cacheWorkDir(isSharedGroup, cacheOrGroupName), partId); - } - /** * @param grpDesc Cache group descriptor. * @param ccfg Cache configuration. @@ -556,7 +549,7 @@ public Path getPath(boolean isSharedGroup, String cacheOrGroupName, int partId) private CacheStoreHolder initForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException { assert !grpDesc.sharedGroup() || ccfg.getGroupName() != null : ccfg.getName(); - File cacheWorkDir = cacheWorkDir(ccfg); + File cacheWorkDir = ft.cacheStorage(ccfg); String dataRegionName = grpDesc.config().getDataRegionName(); DataRegion dataRegion = cctx.database().dataRegion(dataRegionName); @@ -733,7 +726,7 @@ private CacheStoreHolder initDir(File cacheWorkDir, * @return Partition file. */ @NotNull public static File getPartitionFile(File workDir, String cacheDirName, int partId) { - return new File(cacheWorkDir(workDir, cacheDirName), getPartitionFileName(partId)); + return new File(NodeFileTree.cacheStorage(workDir, cacheDirName), getPartitionFileName(partId)); } /** @@ -952,51 +945,6 @@ public static File[] cacheDataFiles(File root) { return pageCnt; } - /** - * @param ccfg Cache configuration. - * @return Store dir for given cache. - */ - public File cacheWorkDir(CacheConfiguration ccfg) { - return cacheWorkDir(ft.nodeStorage(), cacheDirName(ccfg)); - } - - /** - * @param isSharedGroup {@code True} if cache is sharing the same `underlying` cache. - * @param cacheOrGroupName Cache name. - * @return Store directory for given cache. - */ - public File cacheWorkDir(boolean isSharedGroup, String cacheOrGroupName) { - return cacheWorkDir(ft.nodeStorage(), cacheDirName(isSharedGroup, cacheOrGroupName)); - } - - /** - * @param cacheDirName Cache directory name. - * @return Store directory for given cache. - */ - public static File cacheWorkDir(File storeWorkDir, String cacheDirName) { - return new File(storeWorkDir, cacheDirName); - } - - /** - * @param isSharedGroup {@code True} if cache is sharing the same `underlying` cache. - * @param cacheOrGroupName Cache name. - * @return The full cache directory name. - */ - public static String cacheDirName(boolean isSharedGroup, String cacheOrGroupName) { - return isSharedGroup ? CACHE_GRP_DIR_PREFIX + cacheOrGroupName - : CACHE_DIR_PREFIX + cacheOrGroupName; - } - - /** - * @param ccfg Cache configuration. - * @return The full cache directory name. - */ - public static String cacheDirName(CacheConfiguration ccfg) { - boolean isSharedGrp = ccfg.getGroupName() != null; - - return cacheDirName(isSharedGrp, CU.cacheOrGroupName(ccfg)); - } - /** * @param grpId Group id. * @return Name of cache group directory. @@ -1011,7 +959,7 @@ public String cacheDirName(int grpId) throws IgniteCheckedException { if (gctx == null) throw new IgniteCheckedException("Cache group context has not found due to the cache group is stopped."); - return cacheDirName(gctx.config()); + return ft.cacheDirName(gctx.config()); } /** 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 702adcc4e490f..0cb5aacb52d74 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,6 +19,7 @@ import java.io.File; import java.nio.file.Paths; +import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.A; @@ -31,6 +32,8 @@ 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; /** @@ -70,17 +73,17 @@ * │ ├── marshaller ← marshaller (shared between all local nodes) * │ │ └── 1645778359.classname0 * │ ├── node00-e57e62a9-2ccf-4e1b-a11e-c24c21b9ed4c ← nodeStorage (node 0). - * │ │ ├── cache-default + * │ │ ├── cache-default ← cacheStorage (cache name "default"). * │ │ │ ├── cache_data.dat * │ │ │ ├── index.bin * │ │ │ ├── part-0.bin * │ │ │ ├── part-1.bin * ... * │ │ │ └── part-9.bin - * │ │ ├── cache-ignite-sys-cache + * │ │ ├── cache-ignite-sys-cache ← cacheStorage (cache name "ignite-sys-cache"). * │ │ │ ├── cache_data.dat * │ │ │ └── index.bin - * │ │ ├── cache-tx-cache + * │ │ ├── cacheGroup-tx-cache ← cacheStorage (cache group "tx-cache"). * │ │ │ ├── cache_data.dat * │ │ │ ├── index.bin * │ │ │ ├── part-0.bin @@ -97,11 +100,11 @@ * │ │ │ └── part-1.bin * │ │ └── snp ← snpTmp (node 0) * │ ├── node01-e57e62a9-2ccf-4e1b-a11e-d35d32c0fe5d ← nodeStorage (node 1). - * │ │ ├── cache-default + * │ │ ├── cache-default ← cacheStorage (cache name "default"). * .. - * │ │ ├── cache-ignite-sys-cache + * │ │ ├── cache-ignite-sys-cache ← cacheStorage (cache name "ignite-sys-cache"). * ... - * │ │ ├── cache-tx-cache + * │ │ ├── cacheGroup-tx-cache ← cacheStorage (cache group "tx-cache"). * ... * │ │ ├── cp ← checkpoint (node 1). * ... @@ -342,13 +345,67 @@ public boolean walArchiveEnabled() { return walArchive != null && wal != null && !walArchive.equals(wal); } + /** + * @param ccfg Cache configuration. + * @return Store dir for given cache. + */ + public File cacheStorage(CacheConfiguration ccfg) { + return cacheStorage(cacheDirName(ccfg)); + } + + /** + * @param isSharedGroup {@code True} if cache is sharing the same `underlying` cache. + * @param cacheOrGroupName Cache name. + * @return The full cache directory name. + */ + public File cacheStorage(boolean isSharedGroup, String cacheOrGroupName) { + return cacheStorage(cacheDirName(isSharedGroup, cacheOrGroupName)); + } + + /** + * @param ccfg Cache configuration. + * @return The full cache directory name. + */ + public String cacheDirName(CacheConfiguration ccfg) { + boolean isSharedGrp = ccfg.getGroupName() != null; + + return cacheDirName(isSharedGrp, CU.cacheOrGroupName(ccfg)); + } + + /** + * @param cacheDirName Cache directory name. + * @return Store directory for given cache. + */ + public static File cacheStorage(File storeWorkDir, String cacheDirName) { + return new File(storeWorkDir, cacheDirName); + } + + /** + * @param cacheDirName Cache directory name. + * @return Store directory for given cache. + */ + public File cacheStorage(String cacheDirName) { + return new File(nodeStorage, cacheDirName); + } + + /** + * @param isSharedGroup {@code True} if cache is sharing the same `underlying` cache. + * @param cacheOrGroupName Cache name. + * @return The full cache directory name. + */ + private String cacheDirName(boolean isSharedGroup, String cacheOrGroupName) { + return isSharedGroup + ? CACHE_GRP_DIR_PREFIX + cacheOrGroupName + : CACHE_DIR_PREFIX + cacheOrGroupName; + } + /** * Resolves directory specified by the given arguments. * * @param cfg Configured directory path. * @return Initialized directory. */ - public File resolveDirectory(String cfg) { + private File resolveDirectory(String cfg) { File sharedDir = new File(cfg); return sharedDir.isAbsolute() 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 cc1259cdbf00d..cdc456fc09384 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 @@ -3893,7 +3893,7 @@ else if (msg instanceof SnapshotFilesFailureMessage) { try { task.partsLeft.compareAndSet(-1, partsCnt); - File cacheDir = FilePageStoreManager.cacheWorkDir(ft.nodeStorage(), cacheDirName); + File cacheDir = ft.cacheStorage(cacheDirName); File tmpCacheDir = U.resolveWorkDirectory(ft.nodeStorage().getAbsolutePath(), formatTmpDirName(cacheDir).getName(), false); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java index 8a672fb4239ec..27e66490be32a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java @@ -73,8 +73,8 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; -import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheWorkDir; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFile; +import static org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree.cacheStorage; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.copy; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.partDeltaFile; @@ -265,13 +265,13 @@ public IgniteInternalFuture started() { throw new IgniteCheckedException("In-memory cache groups are not allowed to be snapshot: " + grpId); // Create cache group snapshot directory on start in a single thread. - U.ensureDirectory(cacheWorkDir(tmpConsIdDir, FilePageStoreManager.cacheDirName(gctx.config())), + U.ensureDirectory(cacheStorage(tmpConsIdDir, ft.cacheDirName(gctx.config())), "directory for snapshotting cache group", log); } if (withMetaStorage) { - U.ensureDirectory(cacheWorkDir(tmpConsIdDir, MetaStorage.METASTORAGE_DIR_NAME), + U.ensureDirectory(cacheStorage(tmpConsIdDir, MetaStorage.METASTORAGE_DIR_NAME), "directory for snapshotting metastorage", log); } @@ -355,7 +355,7 @@ public IgniteInternalFuture started() { throw new IgniteCheckedException("Cache group is stopped : " + grpId); ccfgs.add(gctx.config()); - addPartitionWriters(grpId, e.getValue(), FilePageStoreManager.cacheDirName(gctx.config())); + addPartitionWriters(grpId, e.getValue(), ft.cacheDirName(gctx.config())); } if (withMetaStorage) { @@ -367,7 +367,7 @@ public IgniteInternalFuture started() { cctx.cache().configManager().readConfigurationFiles(ccfgs, (ccfg, ccfgFile) -> ccfgSndrs.add(new CacheConfigurationSender(ccfg.getName(), - FilePageStoreManager.cacheDirName(ccfg), ccfgFile))); + ft.cacheDirName(ccfg), ccfgFile))); } catch (IgniteCheckedException e) { acceptException(e); @@ -479,7 +479,7 @@ void addPartitionWriters(int grpId, Set parts, String dirName) throws I GroupPartitionId pair = new GroupPartitionId(grpId, partId); PageStore store = pageStore.getStore(grpId, partId); - File delta = partDeltaFile(cacheWorkDir(tmpConsIdDir, dirName), partId); + File delta = partDeltaFile(cacheStorage(tmpConsIdDir, dirName), partId); partDeltaWriters.put(pair, deltaWriterFactory.apply(store, delta, encGrpId)); @@ -623,7 +623,7 @@ public void sendCacheConfig() { if (sent || fromTemp) return; - File cacheWorkDir = cacheWorkDir(tmpSnpWorkDir, cacheDirName); + File cacheWorkDir = cacheStorage(tmpSnpWorkDir, cacheDirName); if (!U.mkdirs(cacheWorkDir)) throw new IOException("Unable to create temp directory to copy original configuration file: " + cacheWorkDir); 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 7674610ea1164..2401defe2ade5 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 @@ -761,7 +761,7 @@ private void enrichContext( } Map cfgsByName = new HashMap<>(); - FilePageStoreManager pageStore = (FilePageStoreManager)cctx.pageStore(); + NodeFileTree ft = ctx.pdsFolderResolver().fileTree(); GridLocalConfigManager locCfgMgr = cctx.cache().configManager(); // Collect the cache configurations and prepare a temporary directory for copying files. @@ -774,7 +774,7 @@ private void enrichContext( if (!F.isEmpty(req.groups()) && !req.groups().contains(grpName)) continue; - File cacheDir = pageStore.cacheWorkDir(snpCacheDir.getName().startsWith(CACHE_GRP_DIR_PREFIX), grpName); + File cacheDir = ft.cacheStorage(snpCacheDir.getName().startsWith(CACHE_GRP_DIR_PREFIX), grpName); if (cacheDir.exists()) { if (!cacheDir.isDirectory()) { @@ -844,12 +844,14 @@ private void finishPrepare(UUID reqId, Map globalCfgs = new HashMap<>(); + NodeFileTree ft = ctx.pdsFolderResolver().fileTree(); + for (Map.Entry e : res.entrySet()) { if (e.getValue().ccfgs != null) { for (StoredCacheData cacheData : e.getValue().ccfgs) { globalCfgs.put(CU.cacheId(cacheData.config().getName()), cacheData); - opCtx0.dirs.add(((FilePageStoreManager)ctx.cache().context().pageStore()).cacheWorkDir(cacheData.config())); + opCtx0.dirs.add(ft.cacheStorage(cacheData.config())); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerFileTransmissionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerFileTransmissionSelfTest.java index 8b84c90cc7f5f..79d6dc63ccde1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerFileTransmissionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerFileTransmissionSelfTest.java @@ -53,11 +53,9 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; -import org.apache.ignite.internal.processors.cache.IgniteInternalCache; 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.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.util.typedef.T2; @@ -208,7 +206,7 @@ public void testFileHandlerBase() throws Exception { } }); - File cacheDirIg0 = cacheWorkDir(snd, DEFAULT_CACHE_NAME); + File cacheDirIg0 = snd.context().pdsFolderResolver().fileTree().cacheStorage(snd.cachex(DEFAULT_CACHE_NAME).configuration()); File[] cacheParts = cacheDirIg0.listFiles(fileBinFilter); @@ -928,22 +926,6 @@ private void addCacheData(Ignite ignite, String cacheName) { } } - /** - * @param ignite An ignite instance. - * @param cacheName Cache name. - * @return The cache working directory. - */ - private File cacheWorkDir(IgniteEx ignite, String cacheName) { - // Resolve cache directory. - IgniteInternalCache cache = ignite.cachex(cacheName); - - FilePageStoreManager pageStoreMgr = (FilePageStoreManager)cache.context() - .shared() - .pageStore(); - - return pageStoreMgr.cacheWorkDir(cache.configuration()); - } - /** * @param name The file name to create. * @param size The file size. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java index 2b6bf346a0e9d..230f8bf7a7861 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java @@ -35,10 +35,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.GridLocalConfigManager; import org.apache.ignite.internal.processors.cache.StoredCacheData; -import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; +import org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.GridTestUtils; @@ -144,11 +143,9 @@ public void testTmpCacheConfigurationsDelete() throws Exception { for (int i = 0; i < NODES; i++) { IgniteEx ig = grid(i); - GridCacheSharedContext sharedCtx = ig.context().cache().context(); + NodeFileTree ft = ig.context().pdsFolderResolver().fileTree(); - FilePageStoreManager pageStore = (FilePageStoreManager)sharedCtx.pageStore(); - - File[] tmpFile = pageStore.cacheWorkDir(true, ODD_GROUP_NAME).listFiles(new FilenameFilter() { + File[] tmpFile = ft.cacheStorage(desc.cacheConfiguration()).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(CACHE_DATA_TMP_FILENAME); } @@ -214,15 +211,13 @@ private void storeTmpCacheData(DynamicCacheDescriptor cacheDescr) throws Excepti for (int i = 0; i < NODES; i++) { IgniteEx ig = grid(i); - GridCacheSharedContext sharedCtx = ig.context().cache().context(); - - FilePageStoreManager pageStore = (FilePageStoreManager)sharedCtx.pageStore(); + NodeFileTree ft = ig.context().pdsFolderResolver().fileTree(); StoredCacheData data = cacheDescr.toStoredData(ig.context().cache().splitter()); data.config().setGroupName(ODD_GROUP_NAME); - File tmp = new File(pageStore.cacheWorkDir(true, ODD_GROUP_NAME), data.config().getName() + CACHE_DATA_TMP_FILENAME); + File tmp = new File(ft.cacheStorage(data.config()), data.config().getName() + CACHE_DATA_TMP_FILENAME); try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(tmp))) { marshaller.marshal(data, stream); @@ -240,15 +235,13 @@ private void corruptCacheData(DynamicCacheDescriptor cacheDescr) throws Exceptio for (int i = 0; i < NODES; i++) { IgniteEx ig = grid(i); - GridCacheSharedContext sharedCtx = ig.context().cache().context(); - - FilePageStoreManager pageStore = (FilePageStoreManager)sharedCtx.pageStore(); + NodeFileTree ft = ig.context().pdsFolderResolver().fileTree(); StoredCacheData data = cacheDescr.toStoredData(ig.context().cache().splitter()); data.config().setGroupName(ODD_GROUP_NAME); - File cfg = new File(pageStore.cacheWorkDir(true, ODD_GROUP_NAME), data.config().getName() + CACHE_DATA_FILENAME); + File cfg = new File(ft.cacheStorage(data.config()), data.config().getName() + CACHE_DATA_FILENAME); try (DataOutputStream os = new DataOutputStream(new FileOutputStream(cfg))) { os.writeLong(-1L); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java index db5ca30441fef..f95681d9ef144 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java @@ -42,6 +42,7 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; 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.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; @@ -399,13 +400,15 @@ private void checkMetricsConsistency(final IgniteEx node) throws Exception { /** */ private void checkMetricsConsistency(final IgniteEx node, String cacheName) throws Exception { FilePageStoreManager pageStoreMgr = (FilePageStoreManager)node.context().cache().context().pageStore(); + NodeFileTree ft = node.context().pdsFolderResolver().fileTree(); assert pageStoreMgr != null : "Persistence is not enabled"; boolean metaStore = METASTORAGE_CACHE_NAME.equals(cacheName); - File cacheWorkDir = metaStore ? new File(node.context().pdsFolderResolver().fileTree().nodeStorage(), METASTORAGE_DIR_NAME) : - pageStoreMgr.cacheWorkDir(node.cachex(cacheName).configuration()); + File cacheWorkDir = metaStore + ? new File(ft.nodeStorage(), METASTORAGE_DIR_NAME) + : ft.cacheStorage(node.cachex(cacheName).configuration()); long totalPersistenceSize = 0; 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 11334ebc45a94..f7a9e5f5a078c 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,7 +77,6 @@ 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.file.FilePageStoreManager; 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; @@ -316,7 +315,7 @@ protected void ensureCacheAbsent(CacheConfiguration ccfg) throws IgniteChe assertTrue("The process has not finished on the node " + kctx.localNodeId(), success); - File dir = ((FilePageStoreManager)kctx.cache().context().pageStore()).cacheWorkDir(ccfg); + File dir = kctx.pdsFolderResolver().fileTree().cacheStorage(ccfg); String errMsg = String.format("%s, dir=%s, exists=%b, files=%s", ignite.name(), dir, dir.exists(), Arrays.toString(dir.list())); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java index e4b8e7bcddcac..09f20378f514d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckTest.java @@ -68,6 +68,7 @@ import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener; 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.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; @@ -88,7 +89,6 @@ import static org.apache.ignite.cluster.ClusterState.ACTIVE; import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE; import static org.apache.ignite.internal.processors.cache.GridCacheUtils.TTL_ETERNAL; -import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirName; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName; import static org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId; import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METAFILE_EXT; @@ -164,11 +164,12 @@ public void testClusterSnapshotCheckMissedPart() throws Exception { @Test public void testClusterSnapshotCheckMissedGroup() throws Exception { IgniteEx ignite = startGridsWithCache(3, dfltCacheCfg, CACHE_KEYS_RANGE); + NodeFileTree ft = ignite.context().pdsFolderResolver().fileTree(); createAndCheckSnapshot(ignite, SNAPSHOT_NAME); Path dir = Files.walk(snp(ignite).snapshotLocalDir(SNAPSHOT_NAME).toPath()) - .filter(d -> d.toFile().getName().equals(cacheDirName(dfltCacheCfg))) + .filter(d -> d.toFile().getName().equals(ft.cacheDirName(dfltCacheCfg))) .findFirst() .orElseThrow(() -> new RuntimeException("Cache directory not found")); @@ -682,7 +683,7 @@ private static void corruptPartitionFile( ) throws IgniteCheckedException, IOException { Path cachePath = Paths.get(snp(ignite).snapshotLocalDir(snpName).getAbsolutePath(), databaseRelativePath(ignite.context().pdsFolderResolver().resolveFolders().folderName()), - cacheDirName(ccfg)); + ignite.context().pdsFolderResolver().fileTree().cacheDirName(ccfg)); Path part0 = U.searchFileRecursively(cachePath, getPartitionFileName(partId)); 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 2f3209ec98395..6b27adde607bb 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 @@ -56,7 +56,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; 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.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType; import org.apache.ignite.internal.util.distributed.SingleNodeMessage; @@ -684,8 +683,7 @@ public void testNodeFailDuringFilesCopy() throws Exception { } })); - File node2dbDir = ((FilePageStoreManager)grid(2).context().cache().context().pageStore()). - cacheWorkDir(dfltCacheCfg).getParentFile(); + File node2dbDir = grid(2).context().pdsFolderResolver().fileTree().cacheStorage(dfltCacheCfg).getParentFile(); IgniteInternalFuture stopFut = runAsync(() -> { U.await(stopLatch, TIMEOUT, TimeUnit.MILLISECONDS); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/PlainSnapshotTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/PlainSnapshotTest.java index 348637139a756..90d77ebfe6b49 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/PlainSnapshotTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/PlainSnapshotTest.java @@ -26,19 +26,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -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.filename.PdsFolderSettings; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; import org.junit.Test; import org.junit.runners.Parameterized; import static org.apache.ignite.cluster.ClusterState.ACTIVE; -import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirName; -import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.databaseRelativePath; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause; /** @@ -102,30 +97,17 @@ public void testSnapshotLocalPartitions() throws Exception { snpFut.get(); - File cacheWorkDir = ((FilePageStoreManager)ig.context() - .cache() - .context() - .pageStore()) - .cacheWorkDir(dfltCacheCfg); - // Checkpoint forces on cluster deactivation (currently only single node in cluster), // so we must have the same data in snapshot partitions and those which left // after node stop. stopGrid(ig.name()); // Calculate CRCs. - PdsFolderSettings settings = ig.context().pdsFolderResolver().resolveFolders(); - String nodePath = databaseRelativePath(settings.folderName()); NodeFileTree ft = ig.context().pdsFolderResolver().fileTree(); - NodeFileTree snpFt = new NodeFileTree(mgr.snapshotLocalDir(SNAPSHOT_NAME).getAbsolutePath(), settings.folderName()); - - final Map origPartCRCs = calculateCRC32Partitions(cacheWorkDir); - final Map snpPartCRCs = calculateCRC32Partitions( - FilePageStoreManager.cacheWorkDir(U.resolveWorkDirectory(mgr.snapshotLocalDir(SNAPSHOT_NAME) - .getAbsolutePath(), - nodePath, - false), - cacheDirName(dfltCacheCfg))); + NodeFileTree snpFt = new NodeFileTree(mgr.snapshotLocalDir(SNAPSHOT_NAME).getAbsolutePath(), ft.folderName()); + + final Map origPartCRCs = calculateCRC32Partitions(ft.cacheStorage(dfltCacheCfg)); + final Map snpPartCRCs = calculateCRC32Partitions(snpFt.cacheStorage(dfltCacheCfg)); assertEquals("Partitions must have the same CRC after file copying and merging partition delta files", origPartCRCs, snpPartCRCs); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractIndexingCommonTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractIndexingCommonTest.java index be12cac67b2fc..c3bcc10bec020 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractIndexingCommonTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractIndexingCommonTest.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.managers.indexing.IndexesRebuildTask; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.query.h2.ConnectionManager; import org.apache.ignite.internal.processors.query.h2.H2PooledConnection; import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; @@ -95,11 +94,7 @@ protected List getIndexBinPaths(String cacheName) { assertNotNull(cachex); - FilePageStoreManager pageStoreMgr = (FilePageStoreManager)cachex.context().shared().pageStore(); - - assertNotNull(pageStoreMgr); - - File cacheWorkDir = pageStoreMgr.cacheWorkDir(cachex.configuration()); + File cacheWorkDir = grid.context().pdsFolderResolver().fileTree().cacheStorage(cachex.configuration()); return cacheWorkDir.toPath().resolve("index.bin"); }) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/RebuildIndexLogMessageTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/RebuildIndexLogMessageTest.java index 6b5d8d7d6d3d3..191cfb504749e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/RebuildIndexLogMessageTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/RebuildIndexLogMessageTest.java @@ -31,7 +31,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -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.typedef.internal.U; import org.apache.ignite.testframework.CallbackExecutorLogListener; import org.apache.ignite.testframework.ListeningTestLogger; @@ -152,10 +152,10 @@ public void testRebuildIndexLogMessage() throws Exception { forceCheckpoint(); - File cacheAWorkDir = ((FilePageStoreManager)cacheAEx.context().shared().pageStore()) - .cacheWorkDir(cacheAEx.configuration()); - File cacheBWorkDir = ((FilePageStoreManager)cacheBEx.context().shared().pageStore()) - .cacheWorkDir(cacheBEx.configuration()); + NodeFileTree ft = ignite.context().pdsFolderResolver().fileTree(); + + File cacheAWorkDir = ft.cacheStorage(cacheAEx.configuration()); + File cacheBWorkDir = ft.cacheStorage(cacheBEx.configuration()); File idxPathA = cacheAWorkDir.toPath().resolve("index.bin").toFile(); File idxPathB = cacheBWorkDir.toPath().resolve("index.bin").toFile(); 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 907ea5976786d..29f52038440ae 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 @@ -91,7 +91,6 @@ 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.file.FilePageStoreManager; 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; @@ -581,9 +580,7 @@ public void testBinaryRecoverBeforePMEWhenMiddleCheckpoint() throws Exception { // Resolve cache directory. Emulating cache destroy in the middle of checkpoint. IgniteInternalCache destoryCache = ig2.cachex(CACHE_TO_DESTROY_NAME); - FilePageStoreManager pageStoreMgr = (FilePageStoreManager)destoryCache.context().shared().pageStore(); - - File destroyCacheWorkDir = pageStoreMgr.cacheWorkDir(destoryCache.configuration()); + File destroyCacheWorkDir = ig2.context().pdsFolderResolver().fileTree().cacheStorage(destoryCache.configuration()); // Stop the whole cluster stopAllGrids(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotMetricsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotMetricsTest.java index ffb9bc69af33f..41d45e07a8e7a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotMetricsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotMetricsTest.java @@ -45,7 +45,6 @@ import org.apache.ignite.internal.IgniteInternalFuture; 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.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.configuration.distributed.DistributedChangeableProperty; import org.apache.ignite.internal.util.typedef.F; @@ -185,7 +184,7 @@ public void testRestoreSnapshotError() throws Exception { IgniteEx ignite = startGridsWithSnapshot(2, CACHE_KEYS_RANGE); - String failingFilePath = Paths.get(FilePageStoreManager.cacheDirName(dfltCacheCfg), + String failingFilePath = Paths.get(ignite.context().pdsFolderResolver().fileTree().cacheDirName(dfltCacheCfg), PART_FILE_PREFIX + primaries[0] + FILE_SUFFIX).toString(); FileIOFactory ioFactory = new RandomAccessFileIOFactory(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java index 6f66104683582..342e6f99d07e2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java @@ -37,7 +37,6 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.index.DynamicIndexAbstractSelfTest; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; -import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; import org.apache.ignite.internal.processors.query.schema.IndexRebuildCancelToken; import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; @@ -299,8 +298,8 @@ private IgniteInternalCache createAndFillTableWithIndex(IgniteEx node) throws Ex protected File indexFile(IgniteInternalCache internalCache) { requireNonNull(internalCache); - File cacheWorkDir = ((FilePageStoreManager)internalCache.context().shared().pageStore()) - .cacheWorkDir(internalCache.configuration()); + File cacheWorkDir = internalCache.context().kernalContext().pdsFolderResolver().fileTree() + .cacheStorage(internalCache.configuration()); return cacheWorkDir.toPath().resolve(INDEX_FILE_NAME).toFile(); }