Package io.microraft
Class RaftConfig
java.lang.Object
io.microraft.RaftConfig
- All Implemented Interfaces:
Serializable
Contains the configuration parameters for MicroRaft's implementation.
RaftConfig is an immutable configuration class. You can use a RaftConfigBuilder to build a RaftConfig object.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Builder for Raft config -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default value forappendEntriesRequestBatchSize
.static final int
The default value forcommitCountToTakeSnapshot
.static final long
The default value forleaderElectionTimeoutMillis
.static final long
The default value forleaderHeartbeatPeriodSecs
.static final long
The default value forleaderHeartbeatTimeoutSecs
static final int
The default value formaxPendingLogEntryCount
.static final RaftConfig
The config object with default configuration.static final int
The default value forraftNodeReportPublishPeriodSecs
.static final boolean
The default value fortransferSnapshotsFromFollowersEnabled
-
Constructor Summary
ConstructorDescriptionRaftConfig
(long leaderElectionTimeoutMillis, long leaderHeartbeatPeriodSecs, long leaderHeartbeatTimeoutSecs, int appendEntriesRequestBatchSize, int commitCountToTakeSnapshot, int maxPendingLogEntryCount, boolean transferSnapshotsFromFollowersEnabled, int raftNodeReportPublishPeriodSecs) Creates a config object -
Method Summary
Modifier and TypeMethodDescriptionint
int
long
long
long
int
int
boolean
static RaftConfig.RaftConfigBuilder
Creates a new Raft config builder.toString()
-
Field Details
-
DEFAULT_LEADER_ELECTION_TIMEOUT_MILLIS
public static final long DEFAULT_LEADER_ELECTION_TIMEOUT_MILLISThe default value forleaderElectionTimeoutMillis
.- See Also:
-
DEFAULT_LEADER_HEARTBEAT_TIMEOUT_SECS
public static final long DEFAULT_LEADER_HEARTBEAT_TIMEOUT_SECSThe default value forleaderHeartbeatTimeoutSecs
- See Also:
-
DEFAULT_LEADER_HEARTBEAT_PERIOD_SECS
public static final long DEFAULT_LEADER_HEARTBEAT_PERIOD_SECSThe default value forleaderHeartbeatPeriodSecs
.- See Also:
-
DEFAULT_MAX_PENDING_LOG_ENTRY_COUNT
public static final int DEFAULT_MAX_PENDING_LOG_ENTRY_COUNTThe default value formaxPendingLogEntryCount
.- See Also:
-
DEFAULT_APPEND_ENTRIES_REQUEST_BATCH_SIZE
public static final int DEFAULT_APPEND_ENTRIES_REQUEST_BATCH_SIZEThe default value forappendEntriesRequestBatchSize
.- See Also:
-
DEFAULT_COMMIT_COUNT_TO_TAKE_SNAPSHOT
public static final int DEFAULT_COMMIT_COUNT_TO_TAKE_SNAPSHOTThe default value forcommitCountToTakeSnapshot
.- See Also:
-
DEFAULT_TRANSFER_SNAPSHOTS_FROM_FOLLOWERS_ENABLED
public static final boolean DEFAULT_TRANSFER_SNAPSHOTS_FROM_FOLLOWERS_ENABLEDThe default value fortransferSnapshotsFromFollowersEnabled
- See Also:
-
DEFAULT_RAFT_NODE_REPORT_PUBLISH_PERIOD_SECS
public static final int DEFAULT_RAFT_NODE_REPORT_PUBLISH_PERIOD_SECSThe default value forraftNodeReportPublishPeriodSecs
.- See Also:
-
DEFAULT_RAFT_CONFIG
The config object with default configuration.
-
-
Constructor Details
-
RaftConfig
public RaftConfig(long leaderElectionTimeoutMillis, long leaderHeartbeatPeriodSecs, long leaderHeartbeatTimeoutSecs, int appendEntriesRequestBatchSize, int commitCountToTakeSnapshot, int maxPendingLogEntryCount, boolean transferSnapshotsFromFollowersEnabled, int raftNodeReportPublishPeriodSecs) Creates a config object- Parameters:
leaderElectionTimeoutMillis
- duration of leader election rounds in millisecondsleaderHeartbeatPeriodSecs
- duration in seconds for a Raft leader node to send periodic heartbeat requests to its followers in order to denote its livelinessleaderHeartbeatTimeoutSecs
- duration in seconds for a follower to decide on failure of the current leader and start a new leader election roundappendEntriesRequestBatchSize
- maximum number of Raft log entries that can be sent as a batch in a single append entries requestcommitCountToTakeSnapshot
- number of new commits to initiate a new snapshot after the last snapshot takenmaxPendingLogEntryCount
- maximum number of pending log entries in the leader's Raft log before temporarily rejecting new requests of clientstransferSnapshotsFromFollowersEnabled
- enable / disable parallel snapshot transfer from followersraftNodeReportPublishPeriodSecs
- how frequently a Raft node publishes a report of its internal Raft state
-
-
Method Details
-
newBuilder
Creates a new Raft config builder.- Returns:
- the builder to populate the parameters for RaftConfig.
-
getLeaderElectionTimeoutMillis
public long getLeaderElectionTimeoutMillis()- Returns:
- the leader election timeout in milliseconds
- See Also:
-
leaderElectionTimeoutMillis
-
getLeaderHeartbeatTimeoutSecs
public long getLeaderHeartbeatTimeoutSecs()- Returns:
- leader heartbeat timeout seconds
- See Also:
-
leaderHeartbeatTimeoutSecs
-
getLeaderHeartbeatPeriodSecs
public long getLeaderHeartbeatPeriodSecs()- Returns:
- the leader election heartbeat period in seconds
- See Also:
-
leaderHeartbeatPeriodSecs
-
getMaxPendingLogEntryCount
public int getMaxPendingLogEntryCount()- Returns:
- the max pending log entry count
- See Also:
-
maxPendingLogEntryCount
-
getAppendEntriesRequestBatchSize
public int getAppendEntriesRequestBatchSize()- Returns:
- the append entries request batch size
- See Also:
-
appendEntriesRequestBatchSize
-
getCommitCountToTakeSnapshot
public int getCommitCountToTakeSnapshot()- Returns:
- the commit count to take snapshot
- See Also:
-
commitCountToTakeSnapshot
-
isTransferSnapshotsFromFollowersEnabled
public boolean isTransferSnapshotsFromFollowersEnabled()- Returns:
- true if the transfer snapshots from followers enabled
- See Also:
-
transferSnapshotsFromFollowersEnabled
-
getRaftNodeReportPublishPeriodSecs
public int getRaftNodeReportPublishPeriodSecs()- Returns:
- the raft node report publish period in seconds
- See Also:
-
raftNodeReportPublishPeriodSecs
-
toString
-