Class SegmentTarReader
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.file.tar.SegmentTarReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,SegmentArchiveReader
public class SegmentTarReader extends Object implements SegmentArchiveReader
-
-
Constructor Summary
Constructors Constructor Description SegmentTarReader(File file, org.apache.jackrabbit.oak.segment.file.tar.FileAccess access, Index index, IOMonitor ioMonitor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the archive.booleancontainsSegment(long msb, long lsb)Check if the segment exists.@NotNull BuffergetBinaryReferences()Load binary references.intgetEntrySize(int size)Transforms the segment size in bytes into the effective size on disk for the given entry (eg.@NotNull SegmentGraphgetGraph()Load the segment graph.@NotNull StringgetName()Get the name of the archive.booleanisRemote()This method returnstrueif the storage is accessed via a network protocol, not tight to the traditional storage technology, for example, HTTP.longlength()Get the current length of the archive.List<SegmentArchiveEntry>listSegments()List all the segments, in the order as they have been written to the archive.static IndexloadAndValidateIndex(RandomAccessFile file, String name)BufferreadSegment(long msb, long lsb)Read the segment.
-
-
-
Method Detail
-
readSegment
public Buffer readSegment(long msb, long lsb) throws IOException
Description copied from interface:SegmentArchiveReaderRead the segment.- Specified by:
readSegmentin interfaceSegmentArchiveReader- Parameters:
msb- the most significant bits of the identifier of the segmentlsb- the least significant bits of the identifier of the segment- Returns:
- byte buffer containing the segment data or null if the segment doesn't exist
- Throws:
IOException
-
containsSegment
public boolean containsSegment(long msb, long lsb)Description copied from interface:SegmentArchiveReaderCheck if the segment exists.- Specified by:
containsSegmentin interfaceSegmentArchiveReader- Parameters:
msb- the most significant bits of the identifier of the segmentlsb- the least significant bits of the identifier of the segment- Returns:
trueif the segment exists
-
listSegments
public List<SegmentArchiveEntry> listSegments()
Description copied from interface:SegmentArchiveReaderList all the segments, in the order as they have been written to the archive.- Specified by:
listSegmentsin interfaceSegmentArchiveReader- Returns:
- segment list, ordered by their position in the archive
-
loadAndValidateIndex
public static Index loadAndValidateIndex(RandomAccessFile file, String name) throws IOException
- Throws:
IOException
-
getGraph
@NotNull public @NotNull SegmentGraph getGraph() throws IOException
Description copied from interface:SegmentArchiveReaderLoad the segment graph.- Specified by:
getGraphin interfaceSegmentArchiveReader- Returns:
- segment graph instance
- Throws:
IOException
-
getBinaryReferences
@NotNull public @NotNull Buffer getBinaryReferences() throws IOException
Description copied from interface:SegmentArchiveReaderLoad binary references.- Specified by:
getBinaryReferencesin interfaceSegmentArchiveReader- Returns:
- byte buffer representing the binary references structure.
- Throws:
IOException
-
length
public long length()
Description copied from interface:SegmentArchiveReaderGet the current length of the archive.- Specified by:
lengthin interfaceSegmentArchiveReader- Returns:
- length of the archive, in bytes
-
getName
@NotNull public @NotNull String getName()
Description copied from interface:SegmentArchiveReaderGet the name of the archive.- Specified by:
getNamein interfaceSegmentArchiveReader- Returns:
- archive name
-
close
public void close() throws IOExceptionDescription copied from interface:SegmentArchiveReaderClose the archive.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSegmentArchiveReader- Throws:
IOException
-
getEntrySize
public int getEntrySize(int size)
Description copied from interface:SegmentArchiveReaderTransforms the segment size in bytes into the effective size on disk for the given entry (eg. by adding the number of padding bytes, header, etc.)- Specified by:
getEntrySizein interfaceSegmentArchiveReader- Parameters:
size- the segment size in bytes- Returns:
- the number of bytes effectively used on the storage to save the segment
-
isRemote
public boolean isRemote()
Description copied from interface:SegmentArchiveReaderThis method returnstrueif the storage is accessed via a network protocol, not tight to the traditional storage technology, for example, HTTP. Based on that info, for instance, calling classes can decide to update archive metadata (graph, binary references, index) more frequently, and not only when the archive is being closed. With that multiple Oak processes can access the storage simultaneously, with one process in read-write mode and one or more processes in read-only mode.- Specified by:
isRemotein interfaceSegmentArchiveReader- Returns:
-
-