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, persistentCache, 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 voidcancelGC()Cancel a running revision garbage collection compaction process as soon as possible.voidcleanup()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.voidclose()voidcollectBlobReferences(Consumer<String> collector)Finds all external blob references that are currently accessible in this repository and adds them to the given collector.booleancompactFull()Copy every referenced record in data (non-bulk) segments.booleancompactTail()booleancontainsSegment(SegmentId id)Checks whether the identified segment exists in this store.voidflush()Flush all pending changesvoidfullGC()Run full garbage collection: estimation, compaction, cleanup.GCNodeWriteMonitorgetGCNodeWriteMonitor()RunnablegetGCRunner()@NotNull TarRevisionsgetRevisions()intgetSegmentCount()FileStoreStatsgetStats()@NotNull SegmentWritergetWriter()intreaderCount()@NotNull SegmentreadSegment(SegmentId id)Reads the identified segment from this store.protected voidregisterCloseables(Closer closer)longsize()voidtailGC()Run tail garbage collection.voidtryFlush()Try to flush all pending changes to disk if possible without waiting for a lock or other resources currently not available.voidwriteSegment(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
doClose, 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 IOExceptionFlush 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 IOExceptionRun full garbage collection: estimation, compaction, cleanup.- Throws:
IOException
-
tailGC
public void tailGC() throws IOExceptionRun 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:
trueon success,falseotherwise.
-
compactTail
public boolean compactTail()
-
cleanup
public void cleanup() throws IOExceptionRun 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:
collectBlobReferencesin 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:
getWriterin classAbstractFileStore
-
getRevisions
@NotNull public @NotNull TarRevisions getRevisions()
- Specified by:
getRevisionsin classAbstractFileStore- Returns:
- the
Revisionsobject bound to the current store.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractFileStore
-
registerCloseables
protected void registerCloseables(Closer closer)
- Overrides:
registerCloseablesin classAbstractFileStore
-
containsSegment
public boolean containsSegment(SegmentId id)
Description copied from interface:SegmentStoreChecks whether the identified segment exists in this store.- Parameters:
id- segment identifier- Returns:
trueif the segment exists,falseotherwise
-
readSegment
@NotNull public @NotNull Segment readSegment(SegmentId id)
Description copied from interface:SegmentStoreReads the identified segment from this store.- Parameters:
id- segment identifier- Returns:
- identified segment, or a
SegmentNotFoundExceptionthrown if not found
-
writeSegment
public void writeSegment(SegmentId id, byte[] buffer, int offset, int length) throws IOException
Description copied from interface:SegmentStoreWrites 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
-
-