Class SegmentAware


  • public class SegmentAware
    extends Object
    Holder of actual information of latest manipulation on WAL segments.
    • Method Detail

      • curAbsWalIdx

        public long curAbsWalIdx()
        Returns:
        Current WAL index.
      • onSegmentCompressed

        public void onSegmentCompressed​(long compressedIdx)
        Callback after segment compression finish.
        Parameters:
        compressedIdx - Index of compressed segment.
      • lastCompressedIdx

        public long lastCompressedIdx()
        Returns:
        Last compressed segment.
      • curAbsWalIdx

        public void curAbsWalIdx​(long curAbsWalIdx)
        Update current WAL index.
        Parameters:
        curAbsWalIdx - New current WAL index.
      • lastTruncatedArchiveIdx

        public void lastTruncatedArchiveIdx​(long absIdx)
        Update last truncated segment.
        Parameters:
        absIdx - Absolut segment index.
      • lastTruncatedArchiveIdx

        public long lastTruncatedArchiveIdx()
        Getting last truncated segment.
        Returns:
        Absolut segment index.
      • setLastArchivedAbsoluteIndex

        public void setLastArchivedAbsoluteIndex​(long lastAbsArchivedIdx)
        Parameters:
        lastAbsArchivedIdx - New value of last archived segment index.
      • lastArchivedAbsoluteIndex

        public long lastArchivedAbsoluteIndex()
        Returns:
        Last archived segment absolute index.
      • reserve

        public boolean reserve​(long absIdx)
        Segment reservation. It will be successful if segment is > than the minimum.
        Parameters:
        absIdx - Index for reservation.
        Returns:
        True if the reservation was successful.
      • reserved

        public boolean reserved​(long absIdx)
        Checks if segment is currently reserved (protected from deletion during WAL cleanup).
        Parameters:
        absIdx - Index for check reservation.
        Returns:
        True if index is reserved.
      • release

        public void release​(long absIdx)
        Parameters:
        absIdx - Reserved index.
      • locked

        public boolean locked​(long absIdx)
        Check if WAL segment locked (protected from move to archive).
        Parameters:
        absIdx - Index for check locking.
        Returns:
        True if index is locked.
      • lock

        public boolean lock​(long absIdx)
        Segment lock. It will be successful if segment is > than the last archived.
        Parameters:
        absIdx - Index to lock.
        Returns:
        True if the lock was successful.
      • unlock

        public void unlock​(long absIdx)
        Parameters:
        absIdx - Index to unlock.
      • reset

        public void reset()
        Reset interrupted flag.
      • interrupt

        public void interrupt()
        Interrupt waiting on related objects.
      • forceInterrupt

        public void forceInterrupt()
        Interrupt waiting on related objects.
      • minReserveIndex

        public boolean minReserveIndex​(long absIdx)
        Increasing minimum segment index after that can be reserved. Value will be updated if it is greater than the current one. If segment is already reserved, the update will fail.
        Parameters:
        absIdx - Absolut segment index.
        Returns:
        True if update is successful.
      • minLockIndex

        public boolean minLockIndex​(long absIdx)
        Increasing minimum segment index after that can be locked. Value will be updated if it is greater than the current one. If segment is already reserved, the update will fail.
        Parameters:
        absIdx - Absolut segment index.
        Returns:
        True if update is successful.
      • addSize

        public void addSize​(long idx,
                            long sizeChange)
        Adding the WAL segment size in the archive.
        Parameters:
        idx - Absolut segment index.
        sizeChange - Segment size in bytes.
      • resetWalArchiveSizes

        public void resetWalArchiveSizes()
        Reset the current and reserved WAL archive sizes.
      • lastCheckpointIdx

        public void lastCheckpointIdx​(long absIdx)
        Update segment of last completed checkpoint. Required for binary recovery.
        Parameters:
        absIdx - Absolut segment index.