org.apache.ignite.internal.processors.cache.persistence.wal.aware

## Class SegmentAware

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware

    public class SegmentAware
    extends Object

Holder of actual information of latest manipulation on WAL segments.

### Constructor Summary

Constructors
Constructor and Description
`SegmentAware(int walSegmentsCnt, boolean compactionEnabled)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `awaitSegment(long absSegIdx)` Waiting until current WAL index will be greater or equal than given one.
`void` `awaitSegmentArchived(long awaitIdx)` Method will wait activation of particular WAL segment index.
`boolean` `checkCanReadArchiveOrReserveWorkSegment(long absIdx)`
`long` `curAbsWalIdx()`
`void` `curAbsWalIdx(long curAbsWalIdx)` Update current WAL index.
`void` `forceInterrupt()` Interrupt waiting on related objects.
`void` `interrupt()` Interrupt waiting on related objects.
`long` `keepUncompressedIdxFrom()`
`void` `keepUncompressedIdxFrom(long idx)`
`long` `lastArchivedAbsoluteIndex()`
`long` `lastCompressedIdx()`
`long` `lastTruncatedArchiveIdx()`
`void` `lastTruncatedArchiveIdx(long lastTruncatedArchiveIdx)`
`boolean` `locked(long absIdx)` Check if WAL segment locked (protected from move to archive)
`void` `markAsMovedToArchive(long toArchive)` Mark segment as moved to archive under lock.
`long` `nextAbsoluteSegmentIndex()` Calculate next segment index or wait if needed.
`void` `onSegmentCompressed(long compressedIdx)` Callback after segment compression finish.
`void` `release(long absIdx)`
`void` `releaseWorkSegment(long absIdx)`
`void` `reserve(long absIdx)`
`boolean` `reserved(long absIdx)` Checks if segment is currently reserved (protected from deletion during WAL cleanup).
`void` `reset()` Reset interrupted flag.
`void` `setLastArchivedAbsoluteIndex(long lastAbsArchivedIdx)`
`long` `waitNextSegmentForArchivation()` Waiting until archivation of next segment will be allowed.
`long` `waitNextSegmentToCompress()` Pessimistically tries to reserve segment for compression in order to avoid concurrent truncation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SegmentAware

    public SegmentAware(int walSegmentsCnt,
                        boolean compactionEnabled)

Parameters:
  `walSegmentsCnt` - Total WAL segments count.
  `compactionEnabled` - Is wal compaction enabled.

### Method Detail

#### awaitSegment

    public void awaitSegment(long absSegIdx)
                      throws IgniteInterruptedCheckedException

Waiting until current WAL index will be greater or equal than given one.

Parameters:
  `absSegIdx` - Target WAL index.
Throws:
  `IgniteInterruptedCheckedException`

#### nextAbsoluteSegmentIndex

    public long nextAbsoluteSegmentIndex()
                                  throws IgniteInterruptedCheckedException

Calculate next segment index or wait if needed.

Returns:
  Next absolute segment index.
Throws:
  `IgniteInterruptedCheckedException`

#### curAbsWalIdx

    public long curAbsWalIdx()

Returns:
  Current WAL index.

#### waitNextSegmentForArchivation

    public long waitNextSegmentForArchivation()
                                       throws IgniteInterruptedCheckedException

Waiting until archivation of next segment will be allowed.

Throws:
  `IgniteInterruptedCheckedException`

#### markAsMovedToArchive

    public void markAsMovedToArchive(long toArchive)
                              throws IgniteInterruptedCheckedException

Mark segment as moved to archive under lock.

Parameters:
  `toArchive` - Segment which was should be moved to archive.
Throws:
  `IgniteInterruptedCheckedException` - if interrupted during waiting.

#### awaitSegmentArchived

    public void awaitSegmentArchived(long awaitIdx)
                              throws IgniteInterruptedCheckedException

Method will wait activation of particular WAL segment index.

Parameters:
  `awaitIdx` - absolute index `lastArchivedAbsoluteIndex()` to become true.
Throws:
  `IgniteInterruptedCheckedException` - if interrupted.

#### waitNextSegmentToCompress

    public long waitNextSegmentToCompress()
                                   throws IgniteInterruptedCheckedException

Pessimistically tries to reserve segment for compression in order to avoid concurrent truncation. Waits if there's no segment to archive right now.

Throws:
  `IgniteInterruptedCheckedException`

#### 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.

#### keepUncompressedIdxFrom

    public void keepUncompressedIdxFrom(long idx)

Parameters:
  `idx` - Minimum raw segment index that should be preserved from deletion.

#### keepUncompressedIdxFrom

    public long keepUncompressedIdxFrom()

Returns:
  Minimum raw segment index that should be preserved from deletion.

#### curAbsWalIdx

    public void curAbsWalIdx(long curAbsWalIdx)

Update current WAL index.

Parameters:
  `curAbsWalIdx` - New current WAL index.

#### lastTruncatedArchiveIdx

    public void lastTruncatedArchiveIdx(long lastTruncatedArchiveIdx)

Parameters:
  `lastTruncatedArchiveIdx` - Last truncated segment;

#### lastTruncatedArchiveIdx

    public long lastTruncatedArchiveIdx()

Returns:
  Last truncated segment.

#### 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 void reserve(long absIdx)

Parameters:
  `absIdx` - Index for reservation.

#### 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 reservation.
Returns:
  `True` if index is locked.

#### checkCanReadArchiveOrReserveWorkSegment

    public boolean checkCanReadArchiveOrReserveWorkSegment(long absIdx)

Parameters:
  `absIdx` - Segment absolute index.
Returns:
  - `True` if can read, no lock is held,
  - `false` if work segment, need release segment later, use `releaseWorkSegment(long)` for unlock

#### releaseWorkSegment

    public void releaseWorkSegment(long absIdx)

Parameters:
  `absIdx` - Segment absolute index.

#### 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.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.1
Release Date | : May 21 2020