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

## Class FileWriteAheadLogManager

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

All Implemented Interfaces:
  IgniteWriteAheadLogManager, GridCacheSharedManager, IgniteChangeGlobalStateSupport

    public class FileWriteAheadLogManager
    extends GridCacheSharedManagerAdapter
    implements IgniteWriteAheadLogManager

File WAL manager.

### Nested Class Summary

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

### Field Summary

Fields
`static FileWriteAheadLogManager.FileDescriptor[]` `EMPTY_DESCRIPTORS`
`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
`FileWriteAheadLogManager(GridKernalContext ctx)`

### Method Summary

Methods
`protected String` `consistentId()`
`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.
`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 FileWriteAheadLogManager.FileDescriptor[]` `scan(File[] allFiles)`
`void` `start0()`
`protected void` `stop0(boolean cancel)`
`int` `truncate(WALPointer ptr)` Gives a hint to WAL manager to clear entries logged before the given pointer.
`int` `walArchiveSegments()`

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

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStop, onKernalStop0, 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, printMemoryStats, start, stop`

### Field Detail

#### EMPTY_DESCRIPTORS

    public static final FileWriteAheadLogManager.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`

### Constructor Detail

#### FileWriteAheadLogManager

    public FileWriteAheadLogManager(@NotNull
                            GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start0

    public void start0()
                throws IgniteCheckedException

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

#### consistentId

    protected String consistentId()

Returns:
  Consistent ID.

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

#### 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 ptr)

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:
  `ptr` - Pointer for which it is safe to clear the log.
Returns:
  Number of deleted WAL segments.

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

#### scan

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

Returns:
  Sorted WAL files descriptors.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017