public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter implements IgniteWriteAheadLogManager
| Modifier and Type | Class and Description |
|---|---|
static class |
FileWriteAheadLogManager.ReadFileHandle |
| Modifier and Type | Field and Description |
|---|---|
static String |
CDC_DISABLED
CDC disabled distributed property name.
|
static double |
DFLT_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE |
static long |
DFLT_THRESHOLD_WAIT_TIME_NEXT_WAL_SEGMENT |
static int |
DFLT_WAL_COMPRESSOR_WORKER_THREAD_CNT |
static boolean |
DFLT_WAL_MMAP |
static Pattern |
WAL_NAME_PATTERN
Pattern for segment file names.
|
static FileFilter |
WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER
WAL segment file filter, see
WAL_NAME_PATTERN |
static Pattern |
WAL_SEGMENT_FILE_COMPACTED_PATTERN |
static FileFilter |
WAL_SEGMENT_FILE_FILTER
WAL segment file filter, see
WAL_NAME_PATTERN |
static Pattern |
WAL_TEMP_NAME_PATTERN
Pattern for WAL temp files - these files will be cleared at startup.
|
cctx, diagnosticLog, log| Constructor and Description |
|---|
FileWriteAheadLogManager(GridKernalContext ctx)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
@Nullable File |
archiveDir()
Archive directory if any.
|
static File |
archiveSegment(File walArchiveDir,
long idx,
String ext) |
void |
awaitCompacted(long idx)
Blocks current thread while segment with the
idx not compressed. |
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.
|
SegmentRouter |
getSegmentRouter() |
Collection<File> |
getWalFilesFromArchive(WALPointer low,
WALPointer high)
Collects WAL segments from the archive only if they are all present.
|
boolean |
isAlwaysWriteFullPages() |
boolean |
isFullSync() |
static boolean |
isSegmentFileName(@Nullable String name)
Check that file name matches segment name.
|
long |
lastArchivedSegment() |
long |
lastCompactedSegment() |
long |
lastTruncatedSegment()
Getting last truncated segment.
|
WALPointer |
lastWritePointer()
Get last written pointer.
|
static FileDescriptor[] |
loadFileDescriptors(File walFilesDir)
Scans provided folder for a WAL segment files
|
WALPointer |
log(WALRecord rec)
Appends the given log entry to the write-ahead log.
|
WALPointer |
log(WALRecord rec,
RolloverType rolloverType)
Appends the given log entry to the write-ahead log.
|
long |
maxWalSegmentSize() |
void |
notchLastCheckpointPtr(WALPointer ptr)
Notifies
this about latest checkpoint pointer. |
void |
onActivate(GridKernalContext kctx)
Called when cluster performing activation.
|
void |
onDeActivate(GridKernalContext kctx)
Called when cluster performing deactivation.
|
static ByteBuffer |
prepareSerializerVersionBuffer(long idx,
int ver,
boolean compacted,
ByteBuffer buf)
Needs only for WAL compaction.
|
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 filePtr)
Resumes logging after start.
|
static FileDescriptor[] |
scan(@Nullable File[] allFiles) |
static long |
segmentIndex(Path segment) |
long |
segmentSize(long idx)
Getting local WAL segment size.
|
int |
serializerVersion() |
void |
setCreateWalFileListener(@Nullable IgniteInClosure<FileIO> createWalFileListener)
Setup listener for WAL segment write File IO creation.
|
void |
setFileIOFactory(FileIOFactory ioFactory)
For test purposes only.
|
void |
start0() |
void |
startAutoReleaseSegments()
Start automatically releasing segments when reaching
DataStorageConfiguration.getMaxWalArchiveSize(). |
protected void |
stop0(boolean cancel)
Method is called twice on deactivate and stop.
|
static long |
totalSize(FileDescriptor... fileDescriptors)
Total size of the segments in bytes.
|
int |
truncate(@Nullable WALPointer high)
Gives a hint to WAL manager to clear entries logged before the given pointer.
|
FileDescriptor[] |
walArchiveFiles()
Files from
walArchiveDir. |
int |
walArchiveSegments() |
@Nullable File |
walCdcDirectory() |
context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onKernalStop0, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitonDisconnected, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stoppublic static final Pattern WAL_NAME_PATTERN
public static final Pattern WAL_TEMP_NAME_PATTERN
public static final FileFilter WAL_SEGMENT_FILE_FILTER
WAL_NAME_PATTERNpublic static final Pattern WAL_SEGMENT_FILE_COMPACTED_PATTERN
public static final FileFilter WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER
WAL_NAME_PATTERNpublic static final boolean DFLT_WAL_MMAP
public static final int DFLT_WAL_COMPRESSOR_WORKER_THREAD_CNT
public static final double DFLT_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE
public static final long DFLT_THRESHOLD_WAIT_TIME_NEXT_WAL_SEGMENT
public static final String CDC_DISABLED
public FileWriteAheadLogManager(GridKernalContext ctx)
ctx - Kernal context.public void setFileIOFactory(FileIOFactory ioFactory)
ioFactory - IO factory.public void start0()
throws IgniteCheckedException
start0 in class GridCacheSharedManagerAdapterIgniteCheckedException - If failed.public SegmentRouter getSegmentRouter()
@Nullable public @Nullable File archiveDir()
archiveDir in interface IgniteWriteAheadLogManagerpublic Collection<File> getWalFilesFromArchive(WALPointer low, WALPointer high) throws IgniteCheckedException
low - Low bound (include).high - High bound (not include).low and high is missing.IgniteCheckedException - If failed.protected void stop0(boolean cancel)
stop0 in class GridCacheSharedManagerAdaptercancel - Cancel flag.public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
onActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.IgniteCheckedException - If failed.public void onDeActivate(GridKernalContext kctx)
onDeActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.public boolean isAlwaysWriteFullPages()
isAlwaysWriteFullPages in interface IgniteWriteAheadLogManagertrue If we have to always write full pages.public boolean isFullSync()
isFullSync in interface IgniteWriteAheadLogManagertrue if WAL will perform fair syncs on fsync call.public void resumeLogging(WALPointer filePtr) throws IgniteCheckedException
resumeLogging in interface IgniteWriteAheadLogManagerIgniteCheckedException - If fails.public int serializerVersion()
serializerVersion in interface IgniteWriteAheadLogManagerpublic WALPointer log(WALRecord rec) throws IgniteCheckedException
log in interface IgniteWriteAheadLogManagerrec - Entry to log.IgniteWriteAheadLogManager.flush(WALPointer, boolean) method to make sure the record is
written to the log.IgniteCheckedException - If failed to construct log entry.StorageException - If IO error occurred while writing log entry.public WALPointer log(WALRecord rec, RolloverType rolloverType) throws IgniteCheckedException
log in interface IgniteWriteAheadLogManagerrec - Entry to log.rolloverType - Rollover type.IgniteWriteAheadLogManager.flush(WALPointer, boolean) method to make sure the record is
written to the log.IgniteCheckedException - If failed to construct log entry.StorageException - If IO error occurred while writing log entry.RolloverTypepublic WALPointer flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException
flush in interface IgniteWriteAheadLogManagerptr - 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.ptr.
May be null, it means nothing has been flushed.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.public WALRecord read(WALPointer ptr) throws IgniteCheckedException, StorageException
read in interface IgniteWriteAheadLogManagerptr - WAL pointer.IgniteCheckedException - If failed to read.StorageException - If IO error occurred while reading WAL entries.public WALIterator replay(WALPointer start) throws IgniteCheckedException, StorageException
replay in interface IgniteWriteAheadLogManagerstart - Optional WAL pointer from which to start iteration.StorageException - If IO error occurred while reading WAL entries.IgniteCheckedExceptionpublic WALIterator replay(WALPointer start, @Nullable @Nullable IgniteBiPredicate<WALRecord.RecordType,WALPointer> recordDeserializeFilter) throws IgniteCheckedException, StorageException
replay in interface IgniteWriteAheadLogManagerstart - Optional WAL pointer from which to start iteration.recordDeserializeFilter - Specify a filter to skip WAL records. Those records will not be explicitly deserialized.StorageException - If IO error occurred while reading WAL entries.IgniteCheckedExceptionpublic boolean reserve(WALPointer start)
DataStorageConfiguration.getMaxWalArchiveSize() is exceeded, the segment will be released.reserve in interface IgniteWriteAheadLogManagerstart - WAL pointer.True if the reservation was successful.public void release(WALPointer start)
release in interface IgniteWriteAheadLogManagerstart - WAL pointer.public int truncate(@Nullable
@Nullable WALPointer high)
truncate in interface IgniteWriteAheadLogManagerhigh - Upper border to which WAL segments will be deleted.public void notchLastCheckpointPtr(WALPointer ptr)
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.
notchLastCheckpointPtr in interface IgniteWriteAheadLogManagerptr - Pointer for which it is safe to compact the log.public long currentSegment()
currentSegment in interface IgniteWriteAheadLogManagerpublic int walArchiveSegments()
walArchiveSegments in interface IgniteWriteAheadLogManagerpublic long lastArchivedSegment()
lastArchivedSegment in interface IgniteWriteAheadLogManagerpublic long lastCompactedSegment()
lastCompactedSegment in interface IgniteWriteAheadLogManagerpublic boolean reserved(WALPointer ptr)
reserved in interface IgniteWriteAheadLogManagerptr - Pointer to check.public int reserved(WALPointer low, WALPointer high)
reserved in interface IgniteWriteAheadLogManagerlow - Pointer since which WAL is locked or reserved. If null, checks from the oldest segment.high - Pointer for which WAL is locked or reserved.public boolean disabled(int grpId,
long pageId)
disabled in interface IgniteWriteAheadLogManagergrpId - Group id.pageId - Page id.public static long segmentIndex(Path segment)
segment - WAL segment file.public FileDescriptor[] walArchiveFiles()
walArchiveDir.public static FileDescriptor[] scan(@Nullable @Nullable File[] allFiles)
public void setCreateWalFileListener(@Nullable
@Nullable IgniteInClosure<FileIO> createWalFileListener)
createWalFileListener - Listener to be invoked for new segment file IO creation.public long maxWalSegmentSize()
maxWalSegmentSize.public File compactedSegment(long idx)
compactedSegment in interface IgniteWriteAheadLogManageridx - Segment index.public void awaitCompacted(long idx)
throws IgniteInterruptedCheckedException
idx not compressed.
If segment compressed, already, returns immediately.awaitCompacted in interface IgniteWriteAheadLogManageridx - Segment index.IgniteInterruptedCheckedExceptionpublic static File archiveSegment(File walArchiveDir, long idx, String ext)
walArchiveDir - WAL archive directory.idx - Segment index.ext - Optional extensionpublic static ByteBuffer prepareSerializerVersionBuffer(long idx, int ver, boolean compacted, ByteBuffer buf)
idx - Index.ver - Version.compacted - Compacted flag.public static FileDescriptor[] loadFileDescriptors(File walFilesDir) throws IgniteCheckedException
walFilesDir - directory to scanIgniteCheckedExceptionpublic long segmentSize(long idx)
segmentSize in interface IgniteWriteAheadLogManageridx - Absolute segment index.0 if size is unknown.public WALPointer lastWritePointer()
lastWritePointer in interface IgniteWriteAheadLogManagerpublic static boolean isSegmentFileName(@Nullable
@Nullable String name)
name - File name.True if file name matches segment name.public long lastTruncatedSegment()
public static long totalSize(FileDescriptor... fileDescriptors)
@Nullable public @Nullable File walCdcDirectory()
public void startAutoReleaseSegments()
DataStorageConfiguration.getMaxWalArchiveSize().startAutoReleaseSegments in interface IgniteWriteAheadLogManager
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.15.0 Release Date : April 25 2023