public class SegmentedRaftLog extends org.neo4j.kernel.lifecycle.LifecycleAdapter implements RaftLog
A RAFT log must be able to append new entries, but also truncate not yet committed entries, prune out old compacted entries and skip to a later starting point.
The RAFT log consists of a sequence of individual log files, called segments, with the following format:
[HEADER] [ENTRY]*
So a header with zero or more entries following it. Each segment file contains a consecutive sequence of appended entries. The operations of truncating and skipping in the log is implemented by switching to the next segment file, called the next version. A new segment file is also started when the threshold for a particular file has been reached.
PHYSICAL_LOG_DIRECTORY_NAME| Constructor and Description |
|---|
SegmentedRaftLog(org.neo4j.io.fs.FileSystemAbstraction fileSystem,
File directory,
long rotateAtSize,
ChannelMarshal<ReplicatedContent> contentMarshal,
org.neo4j.logging.LogProvider logProvider,
int readerPoolSize,
Clock clock,
org.neo4j.kernel.impl.util.JobScheduler scheduler,
CoreLogPruningStrategy pruningStrategy) |
| Modifier and Type | Method and Description |
|---|---|
long |
append(RaftLogEntry... entries)
Appends entry to the end of the log.
|
long |
appendIndex() |
RaftLogCursor |
getEntryCursor(long fromIndex)
Returns a
RaftLogCursor of RaftLogEntrys from the specified index until the end of the log |
long |
prevIndex() |
long |
prune(long safeIndex)
Attempt to prune (delete) a prefix of the log, no further than the safeIndex.
|
long |
readEntryTerm(long logIndex)
Reads the term associated with the entry at the supplied index.
|
long |
skip(long newIndex,
long newTerm)
Skip up to the supplied index if it is not already present.
|
void |
start() |
void |
stop() |
void |
truncate(long fromIndex)
Truncates the log starting from the supplied index.
|
public SegmentedRaftLog(org.neo4j.io.fs.FileSystemAbstraction fileSystem,
File directory,
long rotateAtSize,
ChannelMarshal<ReplicatedContent> contentMarshal,
org.neo4j.logging.LogProvider logProvider,
int readerPoolSize,
Clock clock,
org.neo4j.kernel.impl.util.JobScheduler scheduler,
CoreLogPruningStrategy pruningStrategy)
public void start()
throws IOException,
DamagedLogStorageException,
org.neo4j.causalclustering.core.consensus.log.segmented.DisposedException
start in interface org.neo4j.kernel.lifecycle.Lifecyclestart in class org.neo4j.kernel.lifecycle.LifecycleAdapterIOExceptionDamagedLogStorageExceptionorg.neo4j.causalclustering.core.consensus.log.segmented.DisposedExceptionpublic void stop()
throws Throwable
stop in interface org.neo4j.kernel.lifecycle.Lifecyclestop in class org.neo4j.kernel.lifecycle.LifecycleAdapterThrowablepublic long append(RaftLogEntry... entries) throws IOException
RaftLogappend in interface RaftLogentries - The log entry.IOExceptionpublic void truncate(long fromIndex)
throws IOException
RaftLogtruncate in interface RaftLogfromIndex - The start index (inclusive).IOExceptionpublic long appendIndex()
appendIndex in interface ReadableRaftLogpublic long prevIndex()
prevIndex in interface ReadableRaftLogpublic RaftLogCursor getEntryCursor(long fromIndex) throws IOException
ReadableRaftLogRaftLogCursor of RaftLogEntrys from the specified index until the end of the loggetEntryCursor in interface ReadableRaftLogfromIndex - The log index at which the cursor should be positionedIOExceptionpublic long skip(long newIndex,
long newTerm)
throws IOException
RaftLogskip in interface RaftLognewIndex - the index we want to skip tonewTerm - the term of the indexIOExceptionpublic long readEntryTerm(long logIndex)
throws IOException
ReadableRaftLogreadEntryTerm in interface ReadableRaftLoglogIndex - The index of the log entry.IOExceptionpublic long prune(long safeIndex)
throws IOException
RaftLogprune in interface RaftLogsafeIndex - Highest index that may be pruned.IOExceptionCopyright © 2002–2016 The Neo4j Graph Database Project. All rights reserved.