Class AbstractRemoteSegmentArchiveReader
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.remote.AbstractRemoteSegmentArchiveReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SegmentArchiveReader
- Direct Known Subclasses:
AwsSegmentArchiveReader
,AzureSegmentArchiveReader
public abstract class AbstractRemoteSegmentArchiveReader extends Object implements SegmentArchiveReader
-
-
Constructor Summary
Constructors Constructor Description AbstractRemoteSegmentArchiveReader(IOMonitor ioMonitor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract File
archivePathAsFile()
Returns the decoded file component of this archive.void
close()
Close the archive.protected abstract long
computeArchiveIndexAndLength()
Populates the archive index, summing up each entry's length.boolean
containsSegment(long msb, long lsb)
Check if the segment exists.protected abstract Buffer
doReadDataFile(String extension)
Reads a data file inside the archive.protected abstract void
doReadSegmentToBuffer(String segmentFileName, Buffer buffer)
Reads the segment from the remote storage.Buffer
getBinaryReferences()
Load binary references.int
getEntrySize(int size)
Transforms the segment size in bytes into the effective size on disk for the given entry (eg.Buffer
getGraph()
Load the segment graph.boolean
hasGraph()
Check if the segment graph has been persisted for this archive.boolean
isRemote()
This method returnstrue
if the storage is accessed via a network protocol, not tight to the traditional storage technology, for example, HTTP.List<SegmentArchiveEntry>
listSegments()
List all the segments, in the order as they have been written to the archive.Buffer
readSegment(long msb, long lsb)
Read the segment.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveReader
getName, length
-
-
-
-
Field Detail
-
ioMonitor
protected final IOMonitor ioMonitor
-
index
protected final Map<UUID,RemoteSegmentArchiveEntry> index
-
hasGraph
protected Boolean hasGraph
-
-
Constructor Detail
-
AbstractRemoteSegmentArchiveReader
public AbstractRemoteSegmentArchiveReader(IOMonitor ioMonitor) throws IOException
- Throws:
IOException
-
-
Method Detail
-
readSegment
public Buffer readSegment(long msb, long lsb) throws IOException
Description copied from interface:SegmentArchiveReader
Read the segment.- Specified by:
readSegment
in 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:SegmentArchiveReader
Check if the segment exists.- Specified by:
containsSegment
in interfaceSegmentArchiveReader
- Parameters:
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segment- Returns:
true
if the segment exists
-
listSegments
public List<SegmentArchiveEntry> listSegments()
Description copied from interface:SegmentArchiveReader
List all the segments, in the order as they have been written to the archive.- Specified by:
listSegments
in interfaceSegmentArchiveReader
- Returns:
- segment list, ordered by their position in the archive
-
getGraph
public Buffer getGraph() throws IOException
Description copied from interface:SegmentArchiveReader
Load the segment graph.- Specified by:
getGraph
in interfaceSegmentArchiveReader
- Returns:
- byte buffer representing the graph or null if the graph hasn't been persisted.
- Throws:
IOException
-
hasGraph
public boolean hasGraph()
Description copied from interface:SegmentArchiveReader
Check if the segment graph has been persisted for this archive.- Specified by:
hasGraph
in interfaceSegmentArchiveReader
- Returns:
true
if the graph exists, false otherwise
-
getBinaryReferences
public Buffer getBinaryReferences() throws IOException
Description copied from interface:SegmentArchiveReader
Load binary references.- Specified by:
getBinaryReferences
in interfaceSegmentArchiveReader
- Returns:
- byte buffer representing the binary references structure.
- Throws:
IOException
-
close
public void close()
Description copied from interface:SegmentArchiveReader
Close the archive.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSegmentArchiveReader
-
getEntrySize
public int getEntrySize(int size)
Description copied from interface:SegmentArchiveReader
Transforms 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:
getEntrySize
in interfaceSegmentArchiveReader
- Parameters:
size
- the segment size in bytes- Returns:
- the number of bytes effectively used on the storage to save the segment
-
computeArchiveIndexAndLength
protected abstract long computeArchiveIndexAndLength() throws IOException
Populates the archive index, summing up each entry's length.- Returns:
- length, the total length of the archive
- Throws:
IOException
-
doReadSegmentToBuffer
protected abstract void doReadSegmentToBuffer(String segmentFileName, Buffer buffer) throws IOException
Reads the segment from the remote storage.- Parameters:
segmentFileName
- , the name of the segment (msb + lsb) prefixed by its position in the archivebuffer
- , the buffer to which to read- Throws:
IOException
-
doReadDataFile
protected abstract Buffer doReadDataFile(String extension) throws IOException
Reads a data file inside the archive. This entry is not a segment. Its full name is given by archive name + extension.- Parameters:
extension
- , extension of the file- Returns:
- the buffer containing the data file bytes
- Throws:
IOException
-
archivePathAsFile
protected abstract File archivePathAsFile()
Returns the decoded file component of this archive.- Returns:
- the decoded file component of this archive.
-
isRemote
public boolean isRemote()
Description copied from interface:SegmentArchiveReader
This method returnstrue
if 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:
isRemote
in interfaceSegmentArchiveReader
- Returns:
-
-