Class CommitLogSegment

    • Method Detail

      • additionalHeaderParameters

        protected java.util.Map<java.lang.String,​java.lang.String> additionalHeaderParameters()
        Provide any additional header data that should be stored in the CommitLogDescriptor.
      • createBuffer

        protected java.nio.ByteBuffer createBuffer()
      • resetReplayLimit

        public static void resetReplayLimit()
        FOR TESTING PURPOSES.
      • writeCDCIndexFile

        public static void writeCDCIndexFile​(CommitLogDescriptor desc,
                                             int offset,
                                             boolean complete)
        We persist the offset of the last data synced to disk so clients can parse only durable data if they choose. Data in shared / memory-mapped buffers reflects un-synced data so we need an external sentinel for clients to read to determine actual durable data persisted.
      • writeSyncMarker

        protected static void writeSyncMarker​(long id,
                                              java.nio.ByteBuffer buffer,
                                              int offset,
                                              int filePos,
                                              int nextMarker)
        Create a sync marker to delineate sections of the commit log, typically created on each sync of the file. The sync marker consists of a file pointer to where the next sync marker should be (effectively declaring the length of this section), as well as a CRC value.
        Parameters:
        buffer - buffer in which to write out the sync marker.
        offset - Offset into the buffer at which to write the sync marker.
        filePos - The current position in the target file where the sync marker will be written (most likely different from the buffer position).
        nextMarker - The file position of where the next sync marker should be.
      • isStillAllocating

        public boolean isStillAllocating()
      • getCurrentCommitLogPosition

        public CommitLogPosition getCurrentCommitLogPosition()
        Returns:
        the current CommitLogPosition for this log segment
      • getPath

        public java.lang.String getPath()
        Returns:
        the file path to this segment
      • getName

        public java.lang.String getName()
        Returns:
        the file name of this segment
      • getCDCFile

        public File getCDCFile()
        Returns:
        a File object representing the CDC directory and this file name for hard-linking
      • getCDCIndexFile

        public File getCDCIndexFile()
        Returns:
        a File object representing the CDC Index file holding the offset and completion status of this segment
      • internalClose

        protected void internalClose()
        Close the segment file. Do not call from outside this class, use syncAndClose() instead.
      • coverInMap

        public static <K> void coverInMap​(java.util.concurrent.ConcurrentMap<K,​IntegerInterval> map,
                                          K key,
                                          int value)
      • markClean

        public void markClean​(TableId tableId,
                              CommitLogPosition startPosition,
                              CommitLogPosition endPosition)
        Marks the ColumnFamily specified by id as clean for this log segment. If the given context argument is contained in this file, it will only mark the CF as clean if no newer writes have taken place.
        Parameters:
        tableId - the table that is now clean
        startPosition - the start of the range that is clean
        endPosition - the end of the range that is clean
      • getDirtyTableIds

        public java.util.Collection<TableId> getDirtyTableIds()
        Returns:
        a collection of dirty CFIDs for this segment file.
      • isUnused

        public boolean isUnused()
        Returns:
        true if this segment is unused and safe to recycle or delete
      • contains

        public boolean contains​(CommitLogPosition context)
        Check to see if a certain CommitLogPosition is contained by this segment file.
        Parameters:
        context - the commit log segment position to be checked
        Returns:
        true if the commit log segment position is contained by this segment file.
      • dirtyString

        public java.lang.String dirtyString()
      • onDiskSize

        public abstract long onDiskSize()
      • contentSize

        public long contentSize()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setCDCState

        public CommitLogSegment.CDCState setCDCState​(CommitLogSegment.CDCState newState)
        Change the current cdcState on this CommitLogSegment. There are some restrictions on state transitions and this method is idempotent.
        Returns:
        the old cdc state