org.apache.ignite.internal.pagemem.wal

## Interface IgniteWriteAheadLogManager

All Superinterfaces:
  GridCacheSharedManager, IgniteChangeGlobalStateSupport

All Known Implementing Classes:
  FileWriteAheadLogManager

    public interface IgniteWriteAheadLogManager
    extends GridCacheSharedManager, IgniteChangeGlobalStateSupport

### Method Summary

All Methods Instance Methods Abstract Methods
`@Nullable File` `archiveDir()` Archive directory if any.
`void` `awaitCompacted(long idx)` Blocks current thread while segment with the `idx` not compressed.
`@Nullable File` `compactedSegment(long idx)`
`long` `currentSegment()`
`boolean` `disabled(int grpId, long pageId)` Checks WAL disabled for cache group.
`WALPointer` `flush(WALPointer ptr, boolean explicitFsync)` Makes sure that all log entries written to the log up until the specified pointer are actually written to the underlying storage.
`boolean` `isAlwaysWriteFullPages()`
`boolean` `isFullSync()`
`long` `lastArchivedSegment()`
`long` `lastCompactedSegment()`
`WALPointer` `lastWritePointer()` Get last written pointer.
`WALPointer` `log(WALRecord entry)` Appends the given log entry to the write-ahead log.
`WALPointer` `log(WALRecord entry, RolloverType rolloverType)` Appends the given log entry to the write-ahead log.
`void` `notchLastCheckpointPtr(WALPointer ptr)` Notifies `this` about latest checkpoint pointer.
`WALRecord` `read(WALPointer ptr)` Reads WAL record by the specified pointer.
`void` `release(WALPointer start)` Invoke this method to release WAL history since provided pointer that was previously reserved.
`WALIterator` `replay(WALPointer start)` Invoke this method to iterate over the written log entries.
`WALIterator` `replay(WALPointer start, @Nullable IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordDeserializeFilter)` Invoke this method to iterate over the written log entries.
`boolean` `reserve(WALPointer start)` Invoke this method to reserve WAL history since provided pointer and prevent it's deletion.
`boolean` `reserved(WALPointer ptr)` Checks if WAL segment is under lock or reserved
`int` `reserved(WALPointer low, WALPointer high)` Checks if WAL segments is under lock or reserved.
`void` `resumeLogging(WALPointer lastWrittenPtr)` Resumes logging after start.
`long` `segmentSize(long idx)` Getting local WAL segment size.
`int` `serializerVersion()`
`void` `startAutoReleaseSegments()` Start automatically releasing segments when reaching `DataStorageConfiguration.getMaxWalArchiveSize()`.
`int` `truncate(@Nullable WALPointer high)` Gives a hint to WAL manager to clear entries logged before the given pointer.
`int` `walArchiveSegments()`

### Methods inherited from interface org.apache.ignite.internal.processors.cache.GridCacheSharedManager

`onDisconnected, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stop`

### Methods inherited from interface org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport

`onActivate, onDeActivate`

### Method Detail

#### isAlwaysWriteFullPages

    boolean isAlwaysWriteFullPages()

Returns:
  `true` If we have to always write full pages.

#### isFullSync

    boolean isFullSync()

Returns:
  `true` if WAL will perform fair syncs on fsync call.

#### serializerVersion

    int serializerVersion()

Returns:
  Current serializer version.

#### resumeLogging

    void resumeLogging(WALPointer lastWrittenPtr)
                throws IgniteCheckedException

Resumes logging after start. When WAL manager is started, it will skip logging any updates until this method is called to avoid logging changes induced by the state restore procedure.

Throws:
  `IgniteCheckedException` - If fails.

#### log

    WALPointer log(WALRecord entry)
            throws IgniteCheckedException,
                   StorageException

Appends the given log entry to the write-ahead log.

Parameters:
  `entry` - Entry to log.
Returns:
  WALPointer that may be passed to `flush(WALPointer, boolean)` method to make sure the record is written to the log.
Throws:
  `IgniteCheckedException` - If failed to construct log entry.
  `StorageException` - If IO error occurred while writing log entry.

#### log

    WALPointer log(WALRecord entry,
                   RolloverType rolloverType)
            throws IgniteCheckedException,
                   StorageException

Appends the given log entry to the write-ahead log. If entry logging leads to rollover, caller can specify whether to write the entry to the current segment or to th next one.

Parameters:
  `entry` - Entry to log.
  `rolloverType` - Rollover type.
Returns:
  WALPointer that may be passed to `flush(WALPointer, boolean)` method to make sure the record is written to the log.
Throws:
  `IgniteCheckedException` - If failed to construct log entry.
  `StorageException` - If IO error occurred while writing log entry.
See Also:
  `RolloverType`

#### flush

    WALPointer flush(WALPointer ptr,
                     boolean explicitFsync)
              throws IgniteCheckedException,
                     StorageException

Makes sure that all log entries written to the log up until the specified pointer are actually written to the underlying storage.

Parameters:
  `ptr` - Optional pointer to write. If `null`, will sync up to the latest record.
  `explicitFsync` - If true, data will be synced to the storage device on hardware level.
Returns:
  Last WAL position which was flushed to WAL segment file. May be greater than or equal to a `ptr`. May be `null`, it means nothing has been flushed.
Throws:
  `IgniteCheckedException` - If failed to write.
  `StorageException` - If IO exception occurred during the write. If an exception is thrown from this method, the WAL will be invalidated and the node will be stopped.

#### read

    WALRecord read(WALPointer ptr)
            throws IgniteCheckedException,
                   StorageException

Reads WAL record by the specified pointer.

Parameters:
  `ptr` - WAL pointer.
Returns:
  WAL record.
Throws:
  `IgniteCheckedException` - If failed to read.
  `StorageException` - If IO error occurred while reading WAL entries.

#### replay

    WALIterator replay(WALPointer start)
                throws IgniteCheckedException,
                       StorageException

Invoke this method to iterate over the written log entries.

Parameters:
  `start` - Optional WAL pointer from which to start iteration.
Returns:
  Records iterator.
Throws:
  `IgniteException` - If failed to start iteration.
  `StorageException` - If IO error occurred while reading WAL entries.
  `IgniteCheckedException`

#### replay

    WALIterator replay(WALPointer start,
                       @Nullable
                       @Nullable IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordDeserializeFilter)
                throws IgniteCheckedException,
                       StorageException

Invoke this method to iterate over the written log entries.

Parameters:
  `start` - Optional WAL pointer from which to start iteration.
  `recordDeserializeFilter` - Specify a filter to skip WAL records. Those records will not be explicitly deserialized.
Returns:
  Records iterator.
Throws:
  `IgniteException` - If failed to start iteration.
  `StorageException` - If IO error occurred while reading WAL entries.
  `IgniteCheckedException`

#### reserve

    boolean reserve(WALPointer start)

Invoke this method to reserve WAL history since provided pointer and prevent it's deletion. NOTE: If the `DataStorageConfiguration.getMaxWalArchiveSize()` is exceeded, the segment will be released.

Parameters:
  `start` - WAL pointer.
Returns:
  `True` if the reservation was successful.

#### release

    void release(WALPointer start)

Invoke this method to release WAL history since provided pointer that was previously reserved.

Parameters:
  `start` - WAL pointer.

#### truncate

    int truncate(@Nullable
                 @Nullable WALPointer high)

Gives a hint to WAL manager to clear entries logged before the given pointer. If entries are needed for binary recovery, they will not be affected. Some entries may be reserved eg for historical rebalance and they also will not be affected.

Parameters:
  `high` - Upper border to which WAL segments will be deleted.
Returns:
  Number of deleted WAL segments.

#### notchLastCheckpointPtr

    void notchLastCheckpointPtr(WALPointer ptr)

Notifies `this` about latest checkpoint pointer.

Current implementations, in fact, react by keeping all WAL segments uncompacted starting from index prior to the index of `ptr`. Compaction implies filtering out physical records and ZIP compression.

Parameters:
  `ptr` - Pointer for which it is safe to compact the log.

#### currentSegment

    long currentSegment()

Returns:
  Current segment index.

#### walArchiveSegments

    int walArchiveSegments()

Returns:
  Total number of segments in the WAL archive.

#### lastArchivedSegment

    long lastArchivedSegment()

Returns:
  Last archived segment index.

#### lastCompactedSegment

    long lastCompactedSegment()

Returns:
  Last compacted segment index.

#### reserved

    boolean reserved(WALPointer ptr)

Checks if WAL segment is under lock or reserved

Parameters:
  `ptr` - Pointer to check.
Returns:
  True if given pointer is located in reserved segment.

#### reserved

    int reserved(WALPointer low,
                 WALPointer high)

Checks if WAL segments is under lock or reserved.

Parameters:
  `low` - Pointer since which WAL is locked or reserved. If `null`, checks from the oldest segment.
  `high` - Pointer for which WAL is locked or reserved.
Returns:
  Number of reserved WAL segments.

#### disabled

    boolean disabled(int grpId,
                     long pageId)

Checks WAL disabled for cache group.

Parameters:
  `grpId` - Group id.
  `pageId` - Page id.

#### segmentSize

    long segmentSize(long idx)

Getting local WAL segment size.

Parameters:
  `idx` - Absolute segment index.
Returns:
  Segment size, `0` if size is unknown.

#### lastWritePointer

    WALPointer lastWritePointer()

Get last written pointer.

Returns:
  Last written pointer.

#### startAutoReleaseSegments

    void startAutoReleaseSegments()

Start automatically releasing segments when reaching `DataStorageConfiguration.getMaxWalArchiveSize()`.

#### archiveDir

    @Nullable
    @Nullable File archiveDir()

Archive directory if any.

Returns:
  Archive directory.

#### compactedSegment

    @Nullable
    @Nullable File compactedSegment(long idx)

Parameters:
  `idx` - Segment index.
Returns:
  Compressed archive segment.

#### awaitCompacted

    void awaitCompacted(long idx)
                 throws IgniteInterruptedCheckedException

Blocks current thread while segment with the `idx` not compressed. If segment compressed, already, returns immediately.

Parameters:
  `idx` - Segment index.
Throws:
  `IgniteInterruptedCheckedException`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023