+ private FiniteDuration heartBeatInterval = HEART_BEAT_INTERVAL;
+ private long snapshotBatchCount = SNAPSHOT_BATCH_COUNT;
+ private int journalRecoveryLogBatchSize = JOURNAL_RECOVERY_LOG_BATCH_SIZE;
+ private long isolatedLeaderCheckInterval = HEART_BEAT_INTERVAL.$times(1000).toMillis();
+ private FiniteDuration electionTimeOutInterval;
+
+ // 12 is just an arbitrary percentage. This is the amount of the total memory that a raft actor's
+ // in-memory journal can use before it needs to snapshot
+ private int snapshotDataThresholdPercentage = 12;
+
+ private int snapshotChunkSize = SNAPSHOT_CHUNK_SIZE;
+
+ private long electionTimeoutFactor = 2;
+ private String customRaftPolicyImplementationClass;
+
+ private final Supplier<RaftPolicy> policySupplier = Suppliers.memoize(new PolicySupplier());
+
+ private PeerAddressResolver peerAddressResolver = NoopPeerAddressResolver.INSTANCE;
+
+ private String tempFileDirectory = "";
+
+ private int fileBackedStreamingThreshold = 128 * MEGABYTE;
+
+ public void setHeartBeatInterval(FiniteDuration heartBeatInterval) {
+ this.heartBeatInterval = heartBeatInterval;
+ electionTimeOutInterval = null;
+ }
+
+ public void setSnapshotBatchCount(long snapshotBatchCount) {
+ this.snapshotBatchCount = snapshotBatchCount;
+ }
+
+ public void setSnapshotDataThresholdPercentage(int snapshotDataThresholdPercentage) {
+ this.snapshotDataThresholdPercentage = snapshotDataThresholdPercentage;
+ }
+
+ public void setSnapshotChunkSize(int snapshotChunkSize) {
+ this.snapshotChunkSize = snapshotChunkSize;
+ }
+
+ public void setJournalRecoveryLogBatchSize(int journalRecoveryLogBatchSize) {
+ this.journalRecoveryLogBatchSize = journalRecoveryLogBatchSize;
+ }
+
+ public void setIsolatedLeaderCheckInterval(FiniteDuration isolatedLeaderCheckInterval) {
+ this.isolatedLeaderCheckInterval = isolatedLeaderCheckInterval.toMillis();
+ }
+
+ public void setElectionTimeoutFactor(long electionTimeoutFactor) {
+ this.electionTimeoutFactor = electionTimeoutFactor;
+ electionTimeOutInterval = null;
+ }
+
+ public void setTempFileDirectory(String tempFileDirectory) {
+ this.tempFileDirectory = tempFileDirectory;
+ }
+
+ public void setFileBackedStreamingThreshold(int fileBackedStreamingThreshold) {
+ this.fileBackedStreamingThreshold = fileBackedStreamingThreshold;
+ }
+
+ public void setCustomRaftPolicyImplementationClass(String customRaftPolicyImplementationClass) {
+ this.customRaftPolicyImplementationClass = customRaftPolicyImplementationClass;
+ }
+
+ @Override
+ public String getCustomRaftPolicyImplementationClass() {
+ return customRaftPolicyImplementationClass;
+ }