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

## Class FsyncModeFileWriteAheadLogManager

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
  - - org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager

All Implemented Interfaces:
  IgniteWriteAheadLogManager, GridCacheSharedManager, IgniteChangeGlobalStateSupport

    public class FsyncModeFileWriteAheadLogManager
    extends GridCacheSharedManagerAdapter
    implements IgniteWriteAheadLogManager

File WAL manager.

### Nested Class Summary

Nested Classes
`static class` `FsyncModeFileWriteAheadLogManager.FileDescriptor` WAL file descriptor.
`static class` `FsyncModeFileWriteAheadLogManager.ReadFileHandle`

### Field Summary

Fields
`static FsyncModeFileWriteAheadLogManager.FileDescriptor[]` `EMPTY_DESCRIPTORS`
`static FileFilter` `WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER` WAL segment file filter, see `WAL_NAME_PATTERN`
`static String` `WAL_SEGMENT_FILE_EXT`
`static FileFilter` `WAL_SEGMENT_FILE_FILTER` WAL segment file filter, see `WAL_NAME_PATTERN`

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`FsyncModeFileWriteAheadLogManager(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `allowCompressionUntil(WALPointer ptr)` Gives a hint to WAL manager to compact WAL until given pointer (exclusively).
`boolean` `disabled(int grpId)` Checks WAL disabled for cache group.
`void` `fsync(WALPointer ptr)` Makes sure that all log entries written to the log up until the specified pointer are actually persisted to the underlying storage.
`boolean` `isAlwaysWriteFullPages()`
`boolean` `isFullSync()`
`WALPointer` `log(WALRecord record)` Appends the given log entry to the write-ahead log.
`void` `onActivate(GridKernalContext kctx)` Called when cluster performing activation.
`void` `onDeActivate(GridKernalContext kctx)` Called when cluster performing deactivation.
`static IgniteBiTuple<Integer,Boolean>` `readSerializerVersionAndCompactedFlag(FileIO io)` Reads record serializer version from provided `io` along with compacted flag.
`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.
`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
`void` `resumeLogging(WALPointer lastPtr)` Resumes logging after start.
`static FsyncModeFileWriteAheadLogManager.FileDescriptor[]` `scan(File[] allFiles)`
`int` `serializerVersion()`
`void` `start0()`
`protected void` `stop0(boolean cancel)`
`int` `truncate(WALPointer low, WALPointer high)` Gives a hint to WAL manager to clear entries logged before the given pointer.
`int` `walArchiveSegments()`
`static long` `writeSerializerVersion(FileIO io, long idx, int version, WALMode mode)` Writes record serializer version to provided `io`.

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStop, onKernalStop0, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toString`

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

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

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

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

### Field Detail

#### EMPTY_DESCRIPTORS

    public static final FsyncModeFileWriteAheadLogManager.FileDescriptor[] EMPTY_DESCRIPTORS

#### WAL_SEGMENT_FILE_EXT

    public static final String WAL_SEGMENT_FILE_EXT

See Also:
  Constant Field Values

#### WAL_SEGMENT_FILE_FILTER

    public static final FileFilter WAL_SEGMENT_FILE_FILTER

WAL segment file filter, see `WAL_NAME_PATTERN`

#### WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER

    public static final FileFilter WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER

WAL segment file filter, see `WAL_NAME_PATTERN`

### Constructor Detail

#### FsyncModeFileWriteAheadLogManager

    public FsyncModeFileWriteAheadLogManager(@NotNull
                                             GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start0

    public void start0()
                throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheSharedManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### stop0

    protected void stop0(boolean cancel)

Overrides:
  `stop0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `cancel` - Cancel flag.

#### onActivate

    public void onActivate(GridKernalContext kctx)
                    throws IgniteCheckedException

Called when cluster performing activation.

Specified by:
  `onActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.
Throws:
  `IgniteCheckedException` - If failed.

#### onDeActivate

    public void onDeActivate(GridKernalContext kctx)

Called when cluster performing deactivation.

Specified by:
  `onDeActivate` in interface `IgniteChangeGlobalStateSupport`
Parameters:
  `kctx` - Kernal context.

#### isAlwaysWriteFullPages

    public boolean isAlwaysWriteFullPages()

Specified by:
  `isAlwaysWriteFullPages` in interface `IgniteWriteAheadLogManager`
Returns:
  `true` If we have to always write full pages.

#### isFullSync

    public boolean isFullSync()

Specified by:
  `isFullSync` in interface `IgniteWriteAheadLogManager`
Returns:
  `true` if WAL will perform fair syncs on fsync call.

#### resumeLogging

    public void resumeLogging(WALPointer lastPtr)
                       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.

Specified by:
  `resumeLogging` in interface `IgniteWriteAheadLogManager`
Throws:
  `IgniteCheckedException`

#### serializerVersion

    public int serializerVersion()

Returns:
  Latest serializer version.

#### log

    public WALPointer log(WALRecord record)
                   throws IgniteCheckedException,
                          StorageException

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

Specified by:
  `log` in interface `IgniteWriteAheadLogManager`
Parameters:
  `record` - entry to log.
Returns:
  WALPointer that may be passed to `IgniteWriteAheadLogManager.fsync(WALPointer)` 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.

#### fsync

    public void fsync(WALPointer ptr)
               throws IgniteCheckedException,
                      StorageException

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

Specified by:
  `fsync` in interface `IgniteWriteAheadLogManager`
Parameters:
  `ptr` - Optional pointer to sync. If `null`, will sync up to the latest record.
Throws:
  `IgniteCheckedException` - If failed to fsync.
  `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.

#### replay

    public WALIterator replay(WALPointer start)
                       throws IgniteCheckedException,
                              StorageException

Invoke this method to iterate over the written log entries.

Specified by:
  `replay` in interface `IgniteWriteAheadLogManager`
Parameters:
  `start` - Optional WAL pointer from which to start iteration.
Returns:
  Records iterator.
Throws:
  `StorageException` - If IO error occurred while reading WAL entries.
  `IgniteCheckedException`

#### reserve

    public boolean reserve(WALPointer start)
                    throws IgniteCheckedException

Invoke this method to reserve WAL history since provided pointer and prevent it's deletion.

Specified by:
  `reserve` in interface `IgniteWriteAheadLogManager`
Parameters:
  `start` - WAL pointer.
Throws:
  `IgniteCheckedException`

#### release

    public void release(WALPointer start)
                 throws IgniteCheckedException

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

Specified by:
  `release` in interface `IgniteWriteAheadLogManager`
Parameters:
  `start` - WAL pointer.
Throws:
  `IgniteCheckedException`

#### truncate

    public int truncate(WALPointer low,
                        WALPointer high)

Gives a hint to WAL manager to clear entries logged before the given pointer. Some entries before the the given pointer will be kept because there is a configurable WAL history size. Those entries may be used for partial partition rebalancing.

Specified by:
  `truncate` in interface `IgniteWriteAheadLogManager`
Parameters:
  `low` - Pointer since which WAL will be truncated. If null, WAL will be truncated from the oldest segment.
  `high` - Pointer for which it is safe to clear the log.
Returns:
  Number of deleted WAL segments.

#### allowCompressionUntil

    public void allowCompressionUntil(WALPointer ptr)

Gives a hint to WAL manager to compact WAL until given pointer (exclusively). Compaction implies filtering out physical records and ZIP compression.

Specified by:
  `allowCompressionUntil` in interface `IgniteWriteAheadLogManager`
Parameters:
  `ptr` - Pointer for which it is safe to compact the log.

#### walArchiveSegments

    public int walArchiveSegments()

Specified by:
  `walArchiveSegments` in interface `IgniteWriteAheadLogManager`
Returns:
  Total number of segments in the WAL archive.

#### reserved

    public boolean reserved(WALPointer ptr)

Checks if WAL segment is under lock or reserved

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

#### disabled

    public boolean disabled(int grpId)

Checks WAL disabled for cache group.

Specified by:
  `disabled` in interface `IgniteWriteAheadLogManager`
Parameters:
  `grpId` - Group id.

#### scan

    public static FsyncModeFileWriteAheadLogManager.FileDescriptor[] scan(File[] allFiles)

Returns:
  Sorted WAL files descriptors.

#### readSerializerVersionAndCompactedFlag

    public static IgniteBiTuple<Integer,Boolean> readSerializerVersionAndCompactedFlag(FileIO io)
                                                                                throws IgniteCheckedException,
                                                                                       IOException

Reads record serializer version from provided `io` along with compacted flag. NOTE: Method mutates position of `io`.

Parameters:
  `io` - I/O interface for file.
Returns:
  Serializer version stored in the file.
Throws:
  `IgniteCheckedException` - If failed to read serializer version.
  `IOException`

#### writeSerializerVersion

    public static long writeSerializerVersion(FileIO io,
                                              long idx,
                                              int version,
                                              WALMode mode)
                                       throws IOException

Writes record serializer version to provided `io`. NOTE: Method mutates position of `io`.

Parameters:
  `io` - I/O interface for file.
  `idx` - Segment index.
  `version` - Serializer version.
Returns:
  I/O position after write version.
Throws:
  `IOException` - If failed to write serializer version.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.4.0
Release Date | : March 5 2018