Class DefragmentationFileUtils


  • public class DefragmentationFileUtils
    extends Object
    Everything related to file management during defragmentation process.
    • Constructor Detail

      • DefragmentationFileUtils

        public DefragmentationFileUtils()
    • Method Detail

      • beforeInitPageStores

        public static void beforeInitPageStores​(File workDir,
                                                IgniteLogger log)
                                         throws IgniteCheckedException
        Performs cleanup of work dir before initializing file page stores. Will finish batch renaming if defragmentation was completed or delete garbage if it wasn't.
        Parameters:
        workDir - Cache group working directory.
        log - Logger to write messages.
        Throws:
        IgniteCheckedException - If IOException occurred.
      • deleteLeftovers

        public static void deleteLeftovers​(File workDir)
        Deletes all defragmentation related file from work directory, except for completion marker.
        Parameters:
        workDir - Cache group working directory.
      • skipAlreadyDefragmentedCacheGroup

        public static boolean skipAlreadyDefragmentedCacheGroup​(File workDir,
                                                                int grpId,
                                                                IgniteLogger log)
                                                         throws IgniteException
        Checks whether cache group defragmentation completed or not. Completes it if all that's left is renaming.
        Parameters:
        workDir - Cache group working directory.
        grpId - Cache group Id of cache group belonging to the given working directory.
        log - Logger to write messages.
        Returns:
        true if given cache group is already defragmented.
        Throws:
        IgniteException - If IOException occurred.
        See Also:
        defragmentationCompletionMarkerFile(File)
      • batchRenameDefragmentedCacheGroupPartitions

        public static void batchRenameDefragmentedCacheGroupPartitions​(File workDir,
                                                                       IgniteLogger log)
                                                                throws IgniteException
        Failure-tolerant batch rename of defragmented partition files. Deletes all link mapping files old partition and index files, renaming defragmentated files in the process. Can be run on the same folder multiple times if failed for some reason. Does something only if completion marker is present in the folder. This marker won't be deleted in the end. Deletion of the marker must be done outside of defragmentation mode to prevent cache groups to be defragmentated several times in case of failures.
        Parameters:
        workDir - Cache group working directory.
        log - Logger to write messages.
        Throws:
        IgniteException - If IOException occurred.
        See Also:
        writeDefragmentationCompletionMarker(FileIOFactory, File, IgniteLogger)
      • defragmentedIndexTmpFile

        public static File defragmentedIndexTmpFile​(File workDir)
        Return file named index-dfrg.bin.tmp in given folder. It will be used for storing defragmented index partition during the process.
        Parameters:
        workDir - Cache group working directory.
        Returns:
        File.
        See Also:
        defragmentedIndexFile(File)
      • defragmentedIndexFile

        public static File defragmentedIndexFile​(File workDir)
        Return file named index-dfrg.bin in given folder. It will be used for storing defragmented index partition when the process is over.
        Parameters:
        workDir - Cache group working directory.
        Returns:
        File.
        See Also:
        defragmentedIndexTmpFile(File)
      • defragmentedPartTmpFile

        public static File defragmentedPartTmpFile​(File workDir,
                                                   int partId)
        Return file named part-dfrg-%d.bin.tmp in given folder. It will be used for storing defragmented data partition during the process.
        Parameters:
        workDir - Cache group working directory.
        partId - Partition index, will be substituted into file name.
        Returns:
        File.
        See Also:
        defragmentedPartFile(File, int)
      • defragmentedPartFile

        public static File defragmentedPartFile​(File workDir,
                                                int partId)
        Return file named part-dfrg-%d.bin in given folder. It will be used for storing defragmented data partition when the process is over.
        Parameters:
        workDir - Cache group working directory.
        partId - Partition index, will be substituted into file name.
        Returns:
        File.
        See Also:
        defragmentedPartTmpFile(File, int)
      • defragmentedPartMappingFile

        public static File defragmentedPartMappingFile​(File workDir,
                                                       int partId)
        Return file named part-map-%d.bin in given folder. It will be used for storing defragmention links mapping for given partition during and after defragmentation process. No temporary counterpart is required here.
        Parameters:
        workDir - Cache group working directory.
        partId - Partition index, will be substituted into file name.
        Returns:
        File.
        See Also:
        LinkMap