Class CachingArchiveManager

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void backup​(@NotNull java.lang.String archiveName, @NotNull java.lang.String backupArchiveName, @NotNull java.util.Set<java.util.UUID> recoveredEntries)
      Method that is doing a backup of the archive given with archiveName into backupArchiveName.
      void copyFile​(@NotNull java.lang.String from, @NotNull java.lang.String to)
      Copies the archive with all the segments.
      @NotNull SegmentArchiveWriter create​(@NotNull java.lang.String archiveName)
      Creates a new archive.
      boolean delete​(@NotNull java.lang.String archiveName)
      Deletes the archive if exists.
      boolean exists​(@NotNull java.lang.String archiveName)
      Check if archive exists.
      @Nullable SegmentArchiveReader forceOpen​(java.lang.String archiveName)
      Opens an archive that wasn't closed correctly.
      @NotNull java.util.List<java.lang.String> listArchives()
      List names of the available .tar archives.
      @Nullable SegmentArchiveReader open​(@NotNull java.lang.String archiveName)
      Opens a given archive for reading.
      void recoverEntries​(@NotNull java.lang.String archiveName, @NotNull java.util.LinkedHashMap<java.util.UUID,​byte[]> entries)
      Finds all the segments included in the archive.
      boolean renameTo​(@NotNull java.lang.String from, @NotNull java.lang.String to)
      Renames the archive.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • listArchives

        @NotNull
        public @NotNull java.util.List<java.lang.String> listArchives()
                                                               throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        List names of the available .tar archives.
        Specified by:
        listArchives in interface SegmentArchiveManager
        Returns:
        archive list
        Throws:
        java.io.IOException
      • open

        @Nullable
        public @Nullable SegmentArchiveReader open​(@NotNull
                                                   @NotNull java.lang.String archiveName)
                                            throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        Opens a given archive for reading.
        Specified by:
        open in interface SegmentArchiveManager
        Returns:
        the archive reader or null if the archive doesn't exist or doesn't have a valid index
        Throws:
        java.io.IOException
      • forceOpen

        @Nullable
        public @Nullable SegmentArchiveReader forceOpen​(java.lang.String archiveName)
                                                 throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        Opens an archive that wasn't closed correctly.
        Specified by:
        forceOpen in interface SegmentArchiveManager
        Returns:
        the archive reader or null if the implementation doesn't support opening an unclosed archive
        Throws:
        java.io.IOException
      • delete

        public boolean delete​(@NotNull
                              @NotNull java.lang.String archiveName)
        Description copied from interface: SegmentArchiveManager
        Deletes the archive if exists.
        Specified by:
        delete in interface SegmentArchiveManager
        Returns:
        true if the archive was removed, false otherwise
      • renameTo

        public boolean renameTo​(@NotNull
                                @NotNull java.lang.String from,
                                @NotNull
                                @NotNull java.lang.String to)
        Description copied from interface: SegmentArchiveManager
        Renames the archive.
        Specified by:
        renameTo in interface SegmentArchiveManager
        Parameters:
        from - the existing archive
        to - new name
        Returns:
        true if the archive was renamed, false otherwise
      • copyFile

        public void copyFile​(@NotNull
                             @NotNull java.lang.String from,
                             @NotNull
                             @NotNull java.lang.String to)
                      throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        Copies the archive with all the segments.
        Specified by:
        copyFile in interface SegmentArchiveManager
        Parameters:
        from - the existing archive
        to - new name
        Throws:
        java.io.IOException
      • exists

        public boolean exists​(@NotNull
                              @NotNull java.lang.String archiveName)
        Description copied from interface: SegmentArchiveManager
        Check if archive exists.
        Specified by:
        exists in interface SegmentArchiveManager
        Parameters:
        archiveName - archive to check
        Returns:
        true if archive exists, false otherwise
      • recoverEntries

        public void recoverEntries​(@NotNull
                                   @NotNull java.lang.String archiveName,
                                   @NotNull
                                   @NotNull java.util.LinkedHashMap<java.util.UUID,​byte[]> entries)
                            throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        Finds all the segments included in the archive.
        Specified by:
        recoverEntries in interface SegmentArchiveManager
        Parameters:
        archiveName - archive to recover
        entries - results will be put there, in the order of presence in the archive
        Throws:
        java.io.IOException
      • backup

        public void backup​(@NotNull
                           @NotNull java.lang.String archiveName,
                           @NotNull
                           @NotNull java.lang.String backupArchiveName,
                           @NotNull
                           @NotNull java.util.Set<java.util.UUID> recoveredEntries)
                    throws java.io.IOException
        Description copied from interface: SegmentArchiveManager
        Method that is doing a backup of the archive given with archiveName into backupArchiveName. In addition, set of UUIDs of recovered segments is provided which can be inspected during backup. Method is invoked during archive recovery procedure and concrete implementation can decide whether original archive should be deleted or modified.
        Specified by:
        backup in interface SegmentArchiveManager
        Throws:
        java.io.IOException