public interface RaftLog extends Closeable
RaftLog is a transaction log of a raft service.| 限定符和类型 | 接口和说明 |
|---|---|
static interface |
RaftLog.EntryWithData
Log entry with state machine data.
|
static class |
RaftLogSequentialOps.Runner |
| 限定符和类型 | 字段和说明 |
|---|---|
static long |
INVALID_LOG_INDEX
Invalid log index is used to indicate that the log index is missing.
|
static long |
LEAST_VALID_LOG_INDEX
The least valid log index, i.e. the index used when writing to an empty log.
|
static org.slf4j.Logger |
LOG |
| 限定符和类型 | 方法和说明 |
|---|---|
List<CompletableFuture<Long>> |
append(List<org.apache.ratis.proto.RaftProtos.LogEntryProto> entries)
Append asynchronously all the given log entries.
|
long |
append(long term,
RaftConfiguration configuration)
Append asynchronously a log entry for the given term and configuration
Used by the leader.
|
long |
append(long term,
TransactionContext transaction)
Append asynchronously a log entry for the given term and transaction.
|
default List<CompletableFuture<Long>> |
append(org.apache.ratis.proto.RaftProtos.LogEntryProto... entries)
已过时。
use
append(List) |
CompletableFuture<Long> |
appendEntry(org.apache.ratis.proto.RaftProtos.LogEntryProto entry)
Append asynchronously an entry.
|
default CompletableFuture<Long> |
appendEntry(org.apache.ratis.proto.RaftProtos.LogEntryProto entry,
TransactionContext context)
Append asynchronously an entry.
|
long |
appendMetadata(long term,
long commitIndex)
Append asynchronously a log entry for the given term and commit index
unless the given commit index is an index of a metadata entry
Used by the leader.
|
default boolean |
contains(TermIndex ti)
Does this log contains the given
TermIndex? |
org.apache.ratis.proto.RaftProtos.LogEntryProto |
get(long index) |
LogEntryHeader[] |
getEntries(long startIndex,
long endIndex) |
RaftLog.EntryWithData |
getEntryWithData(long index) |
long |
getFlushIndex() |
long |
getLastCommittedIndex() |
TermIndex |
getLastEntryTermIndex() |
default long |
getNextIndex() |
RaftLogMetrics |
getRaftLogMetrics() |
long |
getSnapshotIndex() |
long |
getStartIndex() |
TermIndex |
getTermIndex(long index) |
RaftStorageMetadata |
loadMetadata()
Load metadata.
|
CompletableFuture<Long> |
onSnapshotInstalled(long lastSnapshotIndex)
A snapshot is installed so that the indices and other information of this log must be updated.
|
void |
open(long lastIndexInSnapshot,
Consumer<org.apache.ratis.proto.RaftProtos.LogEntryProto> consumer)
Open this log for read and write.
|
void |
persistMetadata(RaftStorageMetadata metadata)
Persist the given metadata.
|
CompletableFuture<Long> |
purge(long suggestedIndex)
Purge asynchronously the log transactions.
|
CompletableFuture<Long> |
truncate(long index)
Truncate asynchronously the log entries till the given index (inclusively).
|
boolean |
updateCommitIndex(long majorityIndex,
long currentTerm,
boolean isLeader)
Update the commit index.
|
void |
updateSnapshotIndex(long newSnapshotIndex)
Update the snapshot index with the given index.
|
static final org.slf4j.Logger LOG
static final long LEAST_VALID_LOG_INDEX
static final long INVALID_LOG_INDEX
TermIndex getTermIndex(long index)
TermIndex of the log entry corresponding to the given index.org.apache.ratis.proto.RaftProtos.LogEntryProto get(long index) throws RaftLogIOException
RaftLogIOExceptionRaftLog.EntryWithData getEntryWithData(long index) throws RaftLogIOException
RaftLog.EntryWithData corresponding to the given index.RaftLogIOExceptionLogEntryHeader[] getEntries(long startIndex, long endIndex)
startIndex - the starting log index (inclusive)endIndex - the ending log index (exclusive)long getStartIndex()
default long getNextIndex()
long getLastCommittedIndex()
long getSnapshotIndex()
long getFlushIndex()
RaftLogMetrics getRaftLogMetrics()
RaftLogMetrics.boolean updateCommitIndex(long majorityIndex,
long currentTerm,
boolean isLeader)
majorityIndex - the index that has achieved majority.currentTerm - the current term.isLeader - Is this server the leader?void updateSnapshotIndex(long newSnapshotIndex)
void open(long lastIndexInSnapshot,
Consumer<org.apache.ratis.proto.RaftProtos.LogEntryProto> consumer)
throws IOException
IOExceptionCompletableFuture<Long> purge(long suggestedIndex)
suggestedIndex - the suggested index (inclusive) to be purged.void persistMetadata(RaftStorageMetadata metadata) throws IOException
IOExceptionRaftStorageMetadata loadMetadata() throws IOException
IOExceptionCompletableFuture<Long> onSnapshotInstalled(long lastSnapshotIndex)
long append(long term,
TransactionContext transaction)
throws StateMachineException
StateMachineExceptionlong append(long term,
RaftConfiguration configuration)
long appendMetadata(long term,
long commitIndex)
INVALID_LOG_INDEX.CompletableFuture<Long> appendEntry(org.apache.ratis.proto.RaftProtos.LogEntryProto entry)
default CompletableFuture<Long> appendEntry(org.apache.ratis.proto.RaftProtos.LogEntryProto entry, TransactionContext context)
@Deprecated default List<CompletableFuture<Long>> append(org.apache.ratis.proto.RaftProtos.LogEntryProto... entries)
append(List)List<CompletableFuture<Long>> append(List<org.apache.ratis.proto.RaftProtos.LogEntryProto> entries)
CompletableFuture<Long> truncate(long index)
Copyright © 2017–2025 The Apache Software Foundation. All rights reserved.