Class FilePageStoreManager

    • Constructor Detail

      • FilePageStoreManager

        public FilePageStoreManager​(GridKernalContext ctx)
        Parameters:
        ctx - Kernal context.
    • Method Detail

      • cleanupPageStoreIfMatch

        public void cleanupPageStoreIfMatch​(Predicate<Integer> cacheGrpPred,
                                            boolean cleanFiles)
        Cleanup cache store whether it matches the provided predicate and if matched store was previously initizlized.
        Specified by:
        cleanupPageStoreIfMatch in interface IgnitePageStoreManager
        Parameters:
        cacheGrpPred - Predicate to match by id cache group stores to clean.
        cleanFiles - True to delete all persisted files related to particular store.
      • shutdownForCacheGroup

        public void shutdownForCacheGroup​(CacheGroupContext grp,
                                          boolean destroy)
                                   throws IgniteCheckedException
        Callback called when a cache is stopping. After this callback is invoked, no data associated with the given cache will be stored on disk.
        Specified by:
        shutdownForCacheGroup in interface IgnitePageStoreManager
        Parameters:
        grp - Cache group being stopped.
        destroy - Flag indicating if the cache is being destroyed and data should be cleaned.
        Throws:
        IgniteCheckedException - If failed to handle cache destroy callback.
      • truncate

        public void truncate​(int grpId,
                             int partId,
                             int tag)
                      throws IgniteCheckedException
        Callback called when a partition for the given cache is evicted from the local node. After this callback is invoked, no data associated with the partition will be stored on disk.
        Specified by:
        truncate in interface IgnitePageStoreManager
        Parameters:
        grpId - Cache group ID of the evicted partition.
        partId - Partition ID.
        tag - Partition tag (growing 1-based partition file version).
        Throws:
        IgniteCheckedException - If failed to handle partition destroy callback.
      • read

        public void read​(int grpId,
                         long pageId,
                         ByteBuffer pageBuf,
                         boolean keepCrc)
                  throws IgniteCheckedException
        Reads a page for the given cache ID. Cache ID may be 0 if the page is a meta page.
        Specified by:
        read in interface PageReadWriteManager
        Parameters:
        grpId - Cache group ID.
        pageId - PageID to read.
        pageBuf - Page buffer to write to.
        keepCrc - Keep CRC flag.
        Throws:
        IgniteCheckedException - If failed to read the page.
      • getPath

        public Path getPath​(boolean isSharedGroup,
                            String cacheOrGroupName,
                            int partId)
      • getPageStoreFactory

        public FileVersionCheckingFactory getPageStoreFactory​(int grpId,
                                                              boolean encrypted)
        Parameters:
        grpId - Cache group id.
        encrypted - true if cache group encryption enabled.
        Returns:
        Factory to create page stores.
      • getPageStoreFactory

        public FileVersionCheckingFactory getPageStoreFactory​(int grpId,
                                                              EncryptionCacheKeyProvider encrKeyProvider)
        Parameters:
        grpId - Cache group id.
        encrKeyProvider - Encryption keys provider for encrypted IO. If null, no encryption is used.
        Returns:
        Factory to create page stores with certain encryption keys provider.
      • encryptedFileIoFactory

        public EncryptedFileIOFactory encryptedFileIoFactory​(FileIOFactory plainFileIOFactory,
                                                             int cacheGrpId,
                                                             EncryptionCacheKeyProvider encrKeyProvider)
        Parameters:
        plainFileIOFactory - Not-encrypting file io factory.
        cacheGrpId - Cache group id.
        encrKeyProvider - Encryption keys provider for encrypted IO. If null, no encryption is used.
        Returns:
        Encrypted file IO factory.
      • encryptedFileIoFactory

        public EncryptedFileIOFactory encryptedFileIoFactory​(FileIOFactory plainFileIOFactory,
                                                             int cacheGrpId)
        Returns:
        Encrypted file IO factory with stored internal encryption keys.
      • getPartitionFile

        @NotNull
        public static @NotNull File getPartitionFile​(File workDir,
                                                     String cacheDirName,
                                                     int partId)
        Parameters:
        workDir - Cache work directory.
        cacheDirName - Cache directory name.
        partId - Partition id.
        Returns:
        Partition file.
      • getPartitionFileName

        public static String getPartitionFileName​(int partId)
        Parameters:
        partId - Partition id.
        Returns:
        File name.
      • sync

        public void sync​(int grpId,
                         int partId)
                  throws IgniteCheckedException
        Makes sure that all previous writes to the store has been written to disk.
        Specified by:
        sync in interface IgnitePageStoreManager
        Parameters:
        grpId - Cache group ID to sync.
        partId - Partition ID to sync.
        Throws:
        IgniteCheckedException - If IO error occurred while running sync.
      • cacheDirectories

        public static List<File> cacheDirectories​(File dir,
                                                  Predicate<String> names)
        Parameters:
        dir - Directory to check.
        names - Cache group names to filter.
        Returns:
        Files that match cache or cache group pattern.
      • cacheDirectory

        public static File cacheDirectory​(File dir,
                                          int grpId)
        Parameters:
        dir - Directory to check.
        grpId - Cache group id
        Returns:
        Files that match cache or cache group pattern.
      • partId

        public static int partId​(String partFileName)
        Parameters:
        partFileName - Partition file name.
        Returns:
        Partition id.
      • cachePartitionFiles

        public static List<File> cachePartitionFiles​(File cacheDir)
        Parameters:
        cacheDir - Cache directory to check.
        Returns:
        List of cache partitions in given directory.
      • cachePartitionFiles

        public static List<File> cachePartitionFiles​(File cacheDir,
                                                     String ext)
        Parameters:
        cacheDir - Cache directory to check.
        ext - File extension.
        Returns:
        List of cache partitions in given directory.
      • cacheGroupName

        public static String cacheGroupName​(File dir)
        Parameters:
        dir - Cache directory on disk.
        Returns:
        Cache or cache group name.
      • cacheDataFiles

        public static File[] cacheDataFiles​(File root)
        Parameters:
        root - Root directory.
        Returns:
        Array of cache data files.
      • hasIndexStore

        public boolean hasIndexStore​(int grpId)
        Specified by:
        hasIndexStore in interface IgnitePageStoreManager
        Parameters:
        grpId - Cache group ID.
        Returns:
        True if index store for given cache group existed before node started.
      • pagesAllocated

        public long pagesAllocated​(int grpId)
        Calculates number of pages currently allocated for given cache group.
        Specified by:
        pagesAllocated in interface IgnitePageStoreManager
        Parameters:
        grpId - cache group id.
        Returns:
        number of pages.
      • workDir

        public File workDir()
        Returns:
        Store work dir. Includes consistent-id based folder
      • cacheWorkDir

        public File cacheWorkDir​(CacheConfiguration<?,​?> ccfg)
        Parameters:
        ccfg - Cache configuration.
        Returns:
        Store dir for given cache.
      • cacheWorkDir

        public File cacheWorkDir​(boolean isSharedGroup,
                                 String cacheOrGroupName)
        Parameters:
        isSharedGroup - True if cache is sharing the same `underlying` cache.
        cacheOrGroupName - Cache name.
        Returns:
        Store directory for given cache.
      • cacheWorkDir

        public static File cacheWorkDir​(File storeWorkDir,
                                        String cacheDirName)
        Parameters:
        cacheDirName - Cache directory name.
        Returns:
        Store directory for given cache.
      • cacheDirName

        public static String cacheDirName​(boolean isSharedGroup,
                                          String cacheOrGroupName)
        Parameters:
        isSharedGroup - True if cache is sharing the same `underlying` cache.
        cacheOrGroupName - Cache name.
        Returns:
        The full cache directory name.
      • cacheDirName

        public static String cacheDirName​(CacheConfiguration<?,​?> ccfg)
        Parameters:
        ccfg - Cache configuration.
        Returns:
        The full cache directory name.
      • setPageStoreFileIOFactories

        public void setPageStoreFileIOFactories​(FileIOFactory pageStoreFileIoFactory,
                                                FileIOFactory pageStoreV1FileIoFactory)
        Parameters:
        pageStoreFileIoFactory - File IO factory to override default, may be used for blocked read-write.
        pageStoreV1FileIoFactory - File IO factory for reading V1 page store and for fast touching page files (non blocking).
      • getPageStoreFileIoFactory

        public FileIOFactory getPageStoreFileIoFactory()
        Returns:
        File IO factory currently selected for page store.
      • pageSize

        public int pageSize()
        Returns:
        Durable memory page size in bytes.