Class AbstractRemoteSegmentArchiveWriter

    • 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 java.io.IOException
        Description copied from interface: SegmentArchiveWriter
        Write the new segment to the archive.
        Specified by:
        writeSegment in interface SegmentArchiveWriter
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        data - the data.
        offset - the start offset in the data.
        size - the number of bytes to write.
        generation - the segment generation, see SegmentArchiveEntry.getGeneration()
        fullGeneration - the segment full generation, see SegmentArchiveEntry.getFullGeneration()
        compacted - the segment compaction property, see SegmentArchiveEntry.isCompacted()
        Throws:
        java.io.IOException
      • readSegment

        public Buffer readSegment​(long msb,
                                  long lsb)
                           throws java.io.IOException
        Description copied from interface: SegmentArchiveWriter
        Read the segment.
        Specified by:
        readSegment in interface SegmentArchiveWriter
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - 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:
        java.io.IOException
      • containsSegment

        public boolean containsSegment​(long msb,
                                       long lsb)
        Description copied from interface: SegmentArchiveWriter
        Check if the segment exists.
        Specified by:
        containsSegment in interface SegmentArchiveWriter
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - 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 java.io.IOException
        Description copied from interface: SegmentArchiveWriter
        Write the graph data.
        Specified by:
        writeGraph in interface SegmentArchiveWriter
        Parameters:
        data - serialized segment graph data
        Throws:
        java.io.IOException
      • writeBinaryReferences

        public void writeBinaryReferences​(@NotNull
                                          @org.jetbrains.annotations.NotNull byte[] data)
                                   throws java.io.IOException
        Description copied from interface: SegmentArchiveWriter
        Write the binary references data.
        Specified by:
        writeBinaryReferences in interface SegmentArchiveWriter
        Parameters:
        data - serialized binary references data
        Throws:
        java.io.IOException
      • writeDataFile

        public void writeDataFile​(byte[] data,
                                  java.lang.String extension)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • isCreated

        public boolean isCreated()
        Description copied from interface: SegmentArchiveWriter
        Check if the archive has been created (eg. something has been written).
        Specified by:
        isCreated in interface SegmentArchiveWriter
        Returns:
        true if the archive has been created, false otherwise
      • isRemote

        public boolean isRemote()
        Description copied from interface: SegmentArchiveWriter
        This method returns true 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 interface SegmentArchiveWriter
        Returns:
      • doWriteArchiveEntry

        protected abstract void doWriteArchiveEntry​(RemoteSegmentArchiveEntry indexEntry,
                                                    byte[] data,
                                                    int offset,
                                                    int size)
                                             throws java.io.IOException
        Writes a segment to the remote storage.
        Parameters:
        indexEntry - , the archive index entry to write
        data - , the actual bytes in the entry
        offset - , the start offset in the data.
        size - , the number of bytes to write.
        Throws:
        java.io.IOException
      • doReadArchiveEntry

        protected abstract Buffer doReadArchiveEntry​(RemoteSegmentArchiveEntry indexEntry)
                                              throws java.io.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:
        java.io.IOException
      • doWriteDataFile

        protected abstract void doWriteDataFile​(byte[] data,
                                                java.lang.String extension)
                                         throws java.io.IOException
        Writes 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 write
        extension - , the extension of the data file
        Throws:
        java.io.IOException
      • afterQueueClosed

        protected abstract void afterQueueClosed()
                                          throws java.io.IOException
        Hook for executing additional actions after the segment write queue is closed.
        Throws:
        java.io.IOException
      • afterQueueFlushed

        protected abstract void afterQueueFlushed()
                                           throws java.io.IOException
        Hook for executing additional actions after the segment write queue is flushed.
        Throws:
        java.io.IOException