Class RaftPartitionGroup.Builder

All Implemented Interfaces:
Builder<ManagedPartitionGroup>
Enclosing class:
RaftPartitionGroup

public static class RaftPartitionGroup.Builder extends PartitionGroup.Builder<RaftPartitionGroupConfig>
Raft partition group builder.
  • Constructor Details

  • Method Details

    • withMembers

      public RaftPartitionGroup.Builder withMembers(Collection<String> members)
      Sets the Raft partition group members.
      Parameters:
      members - the Raft partition group members
      Returns:
      the Raft partition group builder
      Throws:
      NullPointerException - if the members are null
    • withMembers

      public RaftPartitionGroup.Builder withMembers(Member... members)
      Sets the Raft partition group members.
      Parameters:
      members - the Raft partition group members
      Returns:
      the Raft partition group builder
      Throws:
      NullPointerException - if the members are null
    • withNumPartitions

      public RaftPartitionGroup.Builder withNumPartitions(int numPartitions)
      Sets the number of partitions.
      Parameters:
      numPartitions - the number of partitions
      Returns:
      the Raft partition group builder
      Throws:
      IllegalArgumentException - if the number of partitions is not positive
    • withPartitionSize

      public RaftPartitionGroup.Builder withPartitionSize(int partitionSize)
      Sets the partition size.
      Parameters:
      partitionSize - the partition size
      Returns:
      the Raft partition group builder
      Throws:
      IllegalArgumentException - if the partition size is not positive
    • withMaxAppendsPerFollower

      public RaftPartitionGroup.Builder withMaxAppendsPerFollower(int maxAppendsPerFollower)
      Sets the maximum append requests which are sent per follower at once. Default is 2.
      Parameters:
      maxAppendsPerFollower - the maximum appends send per follower
      Returns:
      the Raft partition group builder
    • withMaxAppendBatchSize

      public RaftPartitionGroup.Builder withMaxAppendBatchSize(int maxAppendBatchSize)
      Sets the maximum batch size, which is sent per append request. Default size is 32 KB.
      Parameters:
      maxAppendBatchSize - the maximum batch size per append
      Returns:
      the Raft partition group builder
    • withHeartbeatInterval

      public RaftPartitionGroup.Builder withHeartbeatInterval(Duration heartbeatInterval)
      Sets the heartbeatInterval. The leader will send heartbeats to a follower at this interval.
      Parameters:
      heartbeatInterval - the delay between two heartbeats
      Returns:
      the Raft partition group builder
    • withElectionTimeout

      public RaftPartitionGroup.Builder withElectionTimeout(Duration electionTimeout)
      Sets the election timeout. If a follower does not receive a heartbeat from the leader within election timeout, it can start a new leader election.
      Parameters:
      electionTimeout - the election timeout
      Returns:
      the Raft partition group builder
    • withDataDirectory

      public RaftPartitionGroup.Builder withDataDirectory(File dataDir)
      Sets the path to the data directory.
      Parameters:
      dataDir - the path to the replica's data directory
      Returns:
      the replica builder
    • withSegmentSize

      public RaftPartitionGroup.Builder withSegmentSize(long segmentSizeBytes)
      Sets the segment size.
      Parameters:
      segmentSizeBytes - the segment size
      Returns:
      the Raft partition group builder
    • withFreeDiskSpace

      public RaftPartitionGroup.Builder withFreeDiskSpace(long freeDiskSpace)
      Set the minimum free disk space (in bytes) to leave when allocating a new segment
      Parameters:
      freeDiskSpace - free disk space in bytes
      Returns:
      the Raft partition group builder
    • withFlusherFactory

      public RaftPartitionGroup.Builder withFlusherFactory(RaftLogFlusher.Factory flusherFactory)
      Sets the RaftLogFlusher.Factory to create a new flushing strategy for the RaftLog when io.atomix.raft.storage.RaftStorage#openLog(ThreadContext)} is called.
      Parameters:
      flusherFactory - factory to create the flushing strategy for the RaftLog
      Returns:
      the Raft partition group builder
    • withSnapshotStoreFactory

      public RaftPartitionGroup.Builder withSnapshotStoreFactory(ReceivableSnapshotStoreFactory persistedSnapshotStoreFactory)
      Sets the Raft snapshot store factory to use.
      Parameters:
      persistedSnapshotStoreFactory - the new snapshot store factory to use
      Returns:
      the Raft partition group builder
    • withEntryValidator

      public RaftPartitionGroup.Builder withEntryValidator(EntryValidator entryValidator)
      Sets the entry validator to be called when an entry is appended.
      Parameters:
      entryValidator - the entry validator
      Returns:
      the Raft Partition group builder
    • withJournalIndexDensity

      public RaftPartitionGroup.Builder withJournalIndexDensity(int journalIndexDensity)
    • withPriorityElection

      public RaftPartitionGroup.Builder withPriorityElection(boolean enable)
    • withRequestTimeout

      public RaftPartitionGroup.Builder withRequestTimeout(Duration requestTimeout)
      Sets the timeout for all messages sent between raft replicas.
      Parameters:
      requestTimeout - the timeout
      Returns:
      the Raft Partition group builder
    • withMinStepDownFailureCount

      public RaftPartitionGroup.Builder withMinStepDownFailureCount(int minStepDownFailureCount)
      If the leader is not able to reach the quorum, the leader may step down. This is triggered after minStepDownFailureCount number of requests fails to get a response from the quorum of followers as well as if the last response was received before maxQuorumResponseTime.
      Parameters:
      minStepDownFailureCount - The number of failures after which a leader considers stepping down.
      Returns:
      the Raft Partition group builder
    • withMaxQuorumResponseTimeout

      public RaftPartitionGroup.Builder withMaxQuorumResponseTimeout(Duration maxQuorumResponseTimeout)
      If the leader is not able to reach the quorum, the leader may step down. This is triggered * after minStepDownFailureCount number of requests fails to get a response from the quorum of * followers as well as if the last response was received before maxQuorumResponseTime.

      When this value is 0, it will use a default value of electionTimeout * 2.

      Parameters:
      maxQuorumResponseTimeout - the quorum response timeout
      Returns:
      the Raft Partition group builder
    • withPartitionDistributor

      public RaftPartitionGroup.Builder withPartitionDistributor(PartitionDistributor partitionDistributor)
      Sets the partition distributor to use. The partition distributor determines which members will own which partitions, and ensures they are correctly replicated.
      Parameters:
      partitionDistributor - the partition distributor to use
      Returns:
      this builder for chaining
    • withPreferSnapshotReplicationThreshold

      public RaftPartitionGroup.Builder withPreferSnapshotReplicationThreshold(int preferSnapshotReplicationThreshold)
      Sets the threshold for preferring snapshot replication. The unit is number of records by which a follower may lag behind before the leader starts to prefer replicating snapshots instead of records.
      Parameters:
      preferSnapshotReplicationThreshold - the threshold to use
      Returns:
      this builder for chaining
    • withPreallocateSegmentFiles

      public RaftPartitionGroup.Builder withPreallocateSegmentFiles(boolean preallocateSegmentFiles)
      Sets whether segment files are pre-allocated at creation. If true, segment files are pre-allocated to the maximum segment size (see withSegmentSize(long)) at creation before any writes happen.
      Parameters:
      preallocateSegmentFiles - true to preallocate files, false otherwise
      Returns:
      this builder for chaining
    • build

      public RaftPartitionGroup build()