Class SegmentTarWriter
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.file.tar.SegmentTarWriter
-
- All Implemented Interfaces:
SegmentArchiveWriter
public class SegmentTarWriter extends Object implements SegmentArchiveWriter
-
-
Constructor Summary
Constructors Constructor Description SegmentTarWriter(File file, FileStoreMonitor monitor, IOMonitor ioMonitor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the archive.booleancontainsSegment(long msb, long lsb)Check if the segment exists.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.StringgetName()Get the name of the archive.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(byte[] data)Write the binary references data.voidwriteGraph(byte[] data)Write the graph data.voidwriteSegment(long msb, long lsb, byte[] data, int offset, int size, int generation, int fullGeneration, boolean compacted)Write the new segment to the archive.
-
-
-
Constructor Detail
-
SegmentTarWriter
public SegmentTarWriter(File file, FileStoreMonitor monitor, IOMonitor ioMonitor)
-
-
Method Detail
-
writeSegment
public void writeSegment(long msb, long lsb, 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(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(byte[] data) throws IOExceptionDescription copied from interface:SegmentArchiveWriterWrite the binary references data.- Specified by:
writeBinaryReferencesin interfaceSegmentArchiveWriter- Parameters:
data- serialized binary references data- 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
-
getName
public String getName()
Description copied from interface:SegmentArchiveWriterGet the name of the archive.- Specified by:
getNamein interfaceSegmentArchiveWriter- Returns:
- archive name
-
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
-
-