Class FileStore

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, SegmentStore

    public class FileStore
    extends AbstractFileStore
    The storage implementation for tar files.
    • Method Detail

      • getGCRunner

        public java.lang.Runnable getGCRunner()
        Returns:
        a runnable for running garbage collection
      • getGCNodeWriteMonitor

        public GCNodeWriteMonitor getGCNodeWriteMonitor()
        Returns:
        the currently active gc write monitor
      • readerCount

        public int readerCount()
      • getSegmentCount

        public int getSegmentCount()
        Returns:
        the number of segments in the segment store
      • flush

        public void flush()
                   throws java.io.IOException
        Flush all pending changes
        Throws:
        java.io.IOException
      • tryFlush

        public void tryFlush()
        Try to flush all pending changes to disk if possible without waiting for a lock or other resources currently not available.
      • fullGC

        public void fullGC()
                    throws java.io.IOException
        Run full garbage collection: estimation, compaction, cleanup.
        Throws:
        java.io.IOException
      • tailGC

        public void tailGC()
                    throws java.io.IOException
        Run tail garbage collection.
        Throws:
        java.io.IOException
      • compactFull

        public boolean compactFull()
        Copy every referenced record in data (non-bulk) segments. Bulk segments are fully kept (they are only removed in cleanup, if there is no reference to them).
        Returns:
        true on success, false otherwise.
      • compactTail

        public boolean compactTail()
      • cleanup

        public void cleanup()
                     throws java.io.IOException
        Run garbage collection on the segment level: reclaim those data segments that are from an old segment generation and those bulk segments that are not reachable anymore. Those tar files that shrink by at least 25% are rewritten to a new tar generation skipping the reclaimed segments.
        Throws:
        java.io.IOException
      • collectBlobReferences

        public void collectBlobReferences​(java.util.function.Consumer<java.lang.String> collector)
                                   throws java.io.IOException
        Finds all external blob references that are currently accessible in this repository and adds them to the given collector. Useful for collecting garbage in an external data store.

        Note that this method only collects blob references that are already stored in the repository (at the time when this method is called), so the garbage collector will need some other mechanism for tracking in-memory references and references stored while this method is running.

        Specified by:
        collectBlobReferences in class AbstractFileStore
        Parameters:
        collector - reference collector called back for each blob reference found
        Throws:
        java.io.IOException
      • cancelGC

        public void cancelGC()
        Cancel a running revision garbage collection compaction process as soon as possible. Does nothing if gc is not running.
      • close

        public void close()
      • containsSegment

        public boolean containsSegment​(SegmentId id)
        Description copied from interface: SegmentStore
        Checks whether the identified segment exists in this store.
        Parameters:
        id - segment identifier
        Returns:
        true if the segment exists, false otherwise
      • readSegment

        @NotNull
        public @NotNull Segment readSegment​(SegmentId id)
        Description copied from interface: SegmentStore
        Reads the identified segment from this store.
        Parameters:
        id - segment identifier
        Returns:
        identified segment, or a SegmentNotFoundException thrown if not found
      • writeSegment

        public void writeSegment​(SegmentId id,
                                 byte[] buffer,
                                 int offset,
                                 int length)
                          throws java.io.IOException
        Description copied from interface: SegmentStore
        Writes the given segment to the segment store.
        Parameters:
        id - segment identifier
        buffer - byte buffer that contains the raw contents of the segment
        offset - start offset within the byte buffer
        length - length of the segment
        Throws:
        java.io.IOException