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 Modifier and Type Method Description @Nullable FilearchiveDir()Archive directory if any.voidawaitCompacted(long idx)Blocks current thread while segment with theidxnot compressed.@Nullable FilecompactedSegment(long idx)longcurrentSegment()booleandisabled(int grpId, long pageId)Checks WAL disabled for cache group.WALPointerflush(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.booleanisAlwaysWriteFullPages()booleanisFullSync()longlastArchivedSegment()longlastCompactedSegment()WALPointerlastWritePointer()Get last written pointer.WALPointerlog(WALRecord entry)Appends the given log entry to the write-ahead log.WALPointerlog(WALRecord entry, RolloverType rolloverType)Appends the given log entry to the write-ahead log.voidnotchLastCheckpointPtr(WALPointer ptr)Notifiesthisabout latest checkpoint pointer.WALRecordread(WALPointer ptr)Reads WAL record by the specified pointer.voidrelease(WALPointer start)Invoke this method to release WAL history since provided pointer that was previously reserved.WALIteratorreplay(WALPointer start)Invoke this method to iterate over the written log entries.WALIteratorreplay(WALPointer start, @Nullable IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordDeserializeFilter)Invoke this method to iterate over the written log entries.booleanreserve(WALPointer start)Invoke this method to reserve WAL history since provided pointer and prevent it's deletion.booleanreserved(WALPointer ptr)Checks if WAL segment is under lock or reservedintreserved(WALPointer low, WALPointer high)Checks if WAL segments is under lock or reserved.voidresumeLogging(WALPointer lastWrittenPtr)Resumes logging after start.longsegmentSize(long idx)Getting local WAL segment size.intserializerVersion()voidstartAutoReleaseSegments()Start automatically releasing segments when reachingDataStorageConfiguration.getMaxWalArchiveSize().inttruncate(@Nullable WALPointer high)Gives a hint to WAL manager to clear entries logged before the given pointer.intwalArchiveSegments()-
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:
trueIf we have to always write full pages.
-
isFullSync
boolean isFullSync()
- Returns:
trueif 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. Ifnull, 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 benull, 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 theDataStorageConfiguration.getMaxWalArchiveSize()is exceeded, the segment will be released.- Parameters:
start- WAL pointer.- Returns:
Trueif 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)
Notifiesthisabout 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. Ifnull, 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,
0if size is unknown.
-
lastWritePointer
WALPointer lastWritePointer()
Get last written pointer.- Returns:
- Last written pointer.
-
startAutoReleaseSegments
void startAutoReleaseSegments()
Start automatically releasing segments when reachingDataStorageConfiguration.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 IgniteInterruptedCheckedExceptionBlocks current thread while segment with theidxnot compressed. If segment compressed, already, returns immediately.- Parameters:
idx- Segment index.- Throws:
IgniteInterruptedCheckedException
-
-