Class FileStore

java.lang.Object
org.apache.jackrabbit.oak.segment.file.AbstractFileStore
org.apache.jackrabbit.oak.segment.file.FileStore
All Implemented Interfaces:
Closeable, AutoCloseable, SegmentStore

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

    • getGCRunner

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

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

      public long size()
      Returns:
      the size of this store.
    • readerCount

      public int readerCount()
    • getSegmentCount

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

      public FileStoreStats getStats()
    • flush

      public void flush() throws IOException
      Flush all pending changes
      Throws:
      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 IOException
      Run full garbage collection: estimation, compaction, cleanup.
      Throws:
      IOException
    • tailGC

      public void tailGC() throws IOException
      Run tail garbage collection.
      Throws:
      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 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:
      IOException
    • collectBlobReferences

      public void collectBlobReferences(Consumer<String> collector) throws 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:
      IOException
    • cancelGC

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

      @NotNull public @NotNull SegmentWriter getWriter()
      Specified by:
      getWriter in class AbstractFileStore
    • getRevisions

      @NotNull public @NotNull TarRevisions getRevisions()
      Specified by:
      getRevisions in class AbstractFileStore
      Returns:
      the Revisions object bound to the current store.
    • 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 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:
      IOException