Package io.microraft

Class RaftConfig

java.lang.Object
io.microraft.RaftConfig
All Implemented Interfaces:
Serializable

public final class RaftConfig extends Object implements 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:
  • Field Details

    • DEFAULT_LEADER_ELECTION_TIMEOUT_MILLIS

      public static final long DEFAULT_LEADER_ELECTION_TIMEOUT_MILLIS
      The default value for leaderElectionTimeoutMillis.
      See Also:
    • DEFAULT_LEADER_HEARTBEAT_TIMEOUT_SECS

      public static final long DEFAULT_LEADER_HEARTBEAT_TIMEOUT_SECS
      The default value for leaderHeartbeatTimeoutSecs
      See Also:
    • DEFAULT_LEADER_HEARTBEAT_PERIOD_SECS

      public static final long DEFAULT_LEADER_HEARTBEAT_PERIOD_SECS
      The default value for leaderHeartbeatPeriodSecs.
      See Also:
    • DEFAULT_MAX_PENDING_LOG_ENTRY_COUNT

      public static final int DEFAULT_MAX_PENDING_LOG_ENTRY_COUNT
      The default value for maxPendingLogEntryCount.
      See Also:
    • DEFAULT_APPEND_ENTRIES_REQUEST_BATCH_SIZE

      public static final int DEFAULT_APPEND_ENTRIES_REQUEST_BATCH_SIZE
      The default value for appendEntriesRequestBatchSize.
      See Also:
    • DEFAULT_COMMIT_COUNT_TO_TAKE_SNAPSHOT

      public static final int DEFAULT_COMMIT_COUNT_TO_TAKE_SNAPSHOT
      The default value for commitCountToTakeSnapshot.
      See Also:
    • DEFAULT_TRANSFER_SNAPSHOTS_FROM_FOLLOWERS_ENABLED

      public static final boolean DEFAULT_TRANSFER_SNAPSHOTS_FROM_FOLLOWERS_ENABLED
      The default value for transferSnapshotsFromFollowersEnabled
      See Also:
    • DEFAULT_RAFT_NODE_REPORT_PUBLISH_PERIOD_SECS

      public static final int DEFAULT_RAFT_NODE_REPORT_PUBLISH_PERIOD_SECS
      The default value for raftNodeReportPublishPeriodSecs.
      See Also:
    • DEFAULT_RAFT_CONFIG

      public static final RaftConfig 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 milliseconds
      leaderHeartbeatPeriodSecs - duration in seconds for a Raft leader node to send periodic heartbeat requests to its followers in order to denote its liveliness
      leaderHeartbeatTimeoutSecs - duration in seconds for a follower to decide on failure of the current leader and start a new leader election round
      appendEntriesRequestBatchSize - maximum number of Raft log entries that can be sent as a batch in a single append entries request
      commitCountToTakeSnapshot - number of new commits to initiate a new snapshot after the last snapshot taken
      maxPendingLogEntryCount - maximum number of pending log entries in the leader's Raft log before temporarily rejecting new requests of clients
      transferSnapshotsFromFollowersEnabled - enable / disable parallel snapshot transfer from followers
      raftNodeReportPublishPeriodSecs - how frequently a Raft node publishes a report of its internal Raft state
  • Method Details

    • newBuilder

      public static RaftConfig.RaftConfigBuilder 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

      public String toString()
      Overrides:
      toString in class Object