Class AbstractRemoteSegmentArchiveWriter
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.remote.AbstractRemoteSegmentArchiveWriter
-
- All Implemented Interfaces:
SegmentArchiveWriter
- Direct Known Subclasses:
AwsSegmentArchiveWriter,AzureSegmentArchiveWriter,AzureSegmentArchiveWriterV8
public abstract class AbstractRemoteSegmentArchiveWriter extends Object implements SegmentArchiveWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancreatedprotected intentriesprotected Map<UUID,RemoteSegmentArchiveEntry>indexprotected IOMonitorioMonitorprotected FileStoreMonitormonitorprotected Optional<SegmentWriteQueue>queueprotected longtotalLengthprotected WriteAccessControllerwriteAccessController
-
Constructor Summary
Constructors Constructor Description AbstractRemoteSegmentArchiveWriter(IOMonitor ioMonitor, FileStoreMonitor monitor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidafterQueueClosed()Hook for executing additional actions after the segment write queue is closed.protected abstract voidafterQueueFlushed()Hook for executing additional actions after the segment write queue is flushed.voidclose()Close the archive.booleancontainsSegment(long msb, long lsb)Check if the segment exists.protected abstract BufferdoReadArchiveEntry(RemoteSegmentArchiveEntry indexEntry)Reads a segment from remote storage into a buffer.protected abstract voiddoWriteArchiveEntry(RemoteSegmentArchiveEntry indexEntry, byte[] data, int offset, int size)Writes a segment to the remote storage.protected abstract voiddoWriteDataFile(byte[] data, String extension)Writes a data file inside the archive.voidflush()Flush all the data to the storage.intgetEntryCount()Get the number of entries currently contained in the archive.longgetLength()Get the current length of the archive.intgetMaxEntryCount()This method returns the maximum number of segments that can be supported by the underlying persistence implementation of the archive writer.booleanisCreated()Check if the archive has been created (eg.booleanisRemote()This method returnstrueif the storage is accessed via a network protocol, not tied to the traditional storage technology, for example, HTTP.BufferreadSegment(long msb, long lsb)Read the segment.voidwriteBinaryReferences(@org.jetbrains.annotations.NotNull byte[] data)Write the binary references data.voidwriteDataFile(byte[] data, String extension)voidwriteGraph(@org.jetbrains.annotations.NotNull byte[] data)Write the graph data.voidwriteSegment(long msb, long lsb, @org.jetbrains.annotations.NotNull byte[] data, int offset, int size, int generation, int fullGeneration, boolean compacted)Write the new segment to the archive.-
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.SegmentArchiveWriter
getName
-
-
-
-
Field Detail
-
ioMonitor
protected final IOMonitor ioMonitor
-
monitor
protected final FileStoreMonitor monitor
-
queue
protected final Optional<SegmentWriteQueue> queue
-
index
protected Map<UUID,RemoteSegmentArchiveEntry> index
-
entries
protected int entries
-
totalLength
protected long totalLength
-
created
protected volatile boolean created
-
writeAccessController
protected WriteAccessController writeAccessController
-
-
Constructor Detail
-
AbstractRemoteSegmentArchiveWriter
public AbstractRemoteSegmentArchiveWriter(IOMonitor ioMonitor, FileStoreMonitor monitor)
-
-
Method Detail
-
writeSegment
public void writeSegment(long msb, long lsb, @NotNull @org.jetbrains.annotations.NotNull byte[] data, int offset, int size, int generation, int fullGeneration, boolean compacted) throws IOExceptionDescription copied from interface:SegmentArchiveWriterWrite the new segment to the archive.- Specified by:
writeSegmentin interfaceSegmentArchiveWriter- Parameters:
msb- the most significant bits of the identifier of the segmentlsb- the least significant bits of the identifier of the segmentdata- the data.offset- the start offset in the data.size- the number of bytes to write.generation- the segment generation, seeSegmentArchiveEntry.getGeneration()fullGeneration- the segment full generation, seeSegmentArchiveEntry.getFullGeneration()compacted- the segment compaction property, seeSegmentArchiveEntry.isCompacted()- Throws:
IOException- error writing segment
-
readSegment
public Buffer readSegment(long msb, long lsb) throws IOException
Description copied from interface:SegmentArchiveWriterRead the segment.- Specified by:
readSegmentin interfaceSegmentArchiveWriter- 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 segment doesn't exist
- Throws:
IOException
-
containsSegment
public boolean containsSegment(long msb, long lsb)Description copied from interface:SegmentArchiveWriterCheck if the segment exists.- Specified by:
containsSegmentin interfaceSegmentArchiveWriter- 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
-
writeGraph
public void writeGraph(@NotNull @org.jetbrains.annotations.NotNull byte[] data) throws IOExceptionDescription copied from interface:SegmentArchiveWriterWrite the graph data.- Specified by:
writeGraphin interfaceSegmentArchiveWriter- Parameters:
data- serialized segment graph data- Throws:
IOException
-
writeBinaryReferences
public void writeBinaryReferences(@NotNull @org.jetbrains.annotations.NotNull byte[] data) throws IOExceptionDescription copied from interface:SegmentArchiveWriterWrite the binary references data.- Specified by:
writeBinaryReferencesin interfaceSegmentArchiveWriter- Parameters:
data- serialized binary references data- Throws:
IOException
-
writeDataFile
public void writeDataFile(byte[] data, String extension) throws IOException- Throws:
IOException
-
getLength
public long getLength()
Description copied from interface:SegmentArchiveWriterGet the current length of the archive.- Specified by:
getLengthin interfaceSegmentArchiveWriter- Returns:
- length of the archive, in bytes
-
getEntryCount
public int getEntryCount()
Description copied from interface:SegmentArchiveWriterGet the number of entries currently contained in the archive.- Specified by:
getEntryCountin interfaceSegmentArchiveWriter- Returns:
- number of entries
-
close
public void close() throws IOExceptionDescription copied from interface:SegmentArchiveWriterClose the archive.- Specified by:
closein interfaceSegmentArchiveWriter- Throws:
IOException
-
isCreated
public boolean isCreated()
Description copied from interface:SegmentArchiveWriterCheck if the archive has been created (eg. something has been written).- Specified by:
isCreatedin interfaceSegmentArchiveWriter- Returns:
- true if the archive has been created, false otherwise
-
flush
public void flush() throws IOExceptionDescription copied from interface:SegmentArchiveWriterFlush all the data to the storage. After returning from this method successfully, all the segments written with theSegmentArchiveWriter.writeSegment(long, long, byte[], int, int, int, int, boolean)should be actually saved to the storage.- Specified by:
flushin interfaceSegmentArchiveWriter- Throws:
IOException
-
isRemote
public boolean isRemote()
Description copied from interface:SegmentArchiveWriterThis method returnstrueif the storage is accessed via a network protocol, not tied 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 interfaceSegmentArchiveWriter- Returns:
- true if the storage is accessed via a network protocol, false otherwise
-
getMaxEntryCount
public int getMaxEntryCount()
Description copied from interface:SegmentArchiveWriterThis method returns the maximum number of segments that can be supported by the underlying persistence implementation of the archive writer.- Specified by:
getMaxEntryCountin interfaceSegmentArchiveWriter- Returns:
- maximum number of segments supported by the writer implementation
-
doWriteArchiveEntry
protected abstract void doWriteArchiveEntry(RemoteSegmentArchiveEntry indexEntry, byte[] data, int offset, int size) throws IOException
Writes a segment to the remote storage.- Parameters:
indexEntry- , the archive index entry to writedata- , the actual bytes in the entryoffset- , the start offset in the data.size- , the number of bytes to write.- Throws:
IOException
-
doReadArchiveEntry
protected abstract Buffer doReadArchiveEntry(RemoteSegmentArchiveEntry indexEntry) throws IOException
Reads a segment from remote storage into a buffer.- Parameters:
indexEntry- , the archive index entry to read- Returns:
- th buffer containing the segment bytes
- Throws:
IOException
-
doWriteDataFile
protected abstract void doWriteDataFile(byte[] data, String extension) throws IOExceptionWrites a data file inside the archive. This entry is not a segment. Its full name is given by archive name + extension.- Parameters:
data- , bytes to writeextension- , the extension of the data file- Throws:
IOException
-
afterQueueClosed
protected abstract void afterQueueClosed() throws IOExceptionHook for executing additional actions after the segment write queue is closed.- Throws:
IOException
-
afterQueueFlushed
protected abstract void afterQueueFlushed() throws IOExceptionHook for executing additional actions after the segment write queue is flushed.- Throws:
IOException
-
-