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.
-
-
Field Summary
-
Fields inherited from class org.apache.jackrabbit.oak.segment.file.AbstractFileStore
binariesInlineThreshold, ioMonitor, remoteStoreMonitor
-
Fields inherited from interface org.apache.jackrabbit.oak.segment.SegmentStore
EMPTY_STORE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelGC()
Cancel a running revision garbage collection compaction process as soon as possible.void
cleanup()
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.void
close()
void
collectBlobReferences(Consumer<String> collector)
Finds all external blob references that are currently accessible in this repository and adds them to the given collector.boolean
compactFull()
Copy every referenced record in data (non-bulk) segments.boolean
compactTail()
boolean
containsSegment(SegmentId id)
Checks whether the identified segment exists in this store.void
flush()
Flush all pending changesvoid
fullGC()
Run full garbage collection: estimation, compaction, cleanup.GCNodeWriteMonitor
getGCNodeWriteMonitor()
Runnable
getGCRunner()
@NotNull TarRevisions
getRevisions()
int
getSegmentCount()
FileStoreStats
getStats()
@NotNull SegmentWriter
getWriter()
int
readerCount()
@NotNull Segment
readSegment(SegmentId id)
Reads the identified segment from this store.long
size()
void
tailGC()
Run tail garbage collection.void
tryFlush()
Try to flush all pending changes to disk if possible without waiting for a lock or other resources currently not available.void
writeSegment(SegmentId id, byte[] buffer, int offset, int length)
Writes the given segment to the segment store.-
Methods inherited from class org.apache.jackrabbit.oak.segment.file.AbstractFileStore
getBinariesInlineThreshold, getBlobStore, getHead, getReader, getSegmentCacheStats, getSegmentIdProvider, getStringCacheStats, getTemplateCacheStats
-
-
-
-
Method Detail
-
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 classAbstractFileStore
- 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 classAbstractFileStore
-
getRevisions
@NotNull public @NotNull TarRevisions getRevisions()
- Specified by:
getRevisions
in classAbstractFileStore
- 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 identifierbuffer
- byte buffer that contains the raw contents of the segmentoffset
- start offset within the byte bufferlength
- length of the segment- Throws:
IOException
-
-