2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.raft;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
12 import scala.concurrent.duration.FiniteDuration;
15 * Configuration Parameter interface for configuring the Raft consensus system
18 * Any component using this implementation might want to provide an implementation of
19 * this interface to configure
22 * A default implementation will be used if none is provided.
24 * @author Kamal Rameshan
26 public interface ConfigParams {
27 int MEGABYTE = 1048576;
30 * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
32 * @return the minimum number of entries.
34 long getSnapshotBatchCount();
37 * Returns the percentage of total memory used in the in-memory Raft log before a snapshot should be taken.
39 * @return the percentage.
41 int getSnapshotDataThresholdPercentage();
45 * Returns the interval(in seconds) after which a snapshot should be taken during recovery.
46 * Negative value means don't take snapshots.
48 * @return the interval of recovery snapshot in seconds
50 int getRecoverySnapshotIntervalSeconds();
53 * Returns the interval at which a heart beat message should be sent to remote followers.
55 * @return the interval as a FiniteDuration.
57 FiniteDuration getHeartBeatInterval();
60 * Returns the interval after which a new election should be triggered if no leader is available.
62 * @return the interval as a FiniteDuration.
64 FiniteDuration getElectionTimeOutInterval();
67 * Returns the number by which a candidate should divide the election timeout it has calculated. This serves
68 * to speed up retries when elections result in a stalemate.
70 * @return the interval as a FiniteDuration.
72 long getCandidateElectionTimeoutDivisor();
75 * Returns the maximum election time variance. The election is scheduled using both the election timeout
78 * @return the election time variance.
80 int getElectionTimeVariance();
83 * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
85 * @return the maximum size (in bytes).
87 int getSnapshotChunkSize();
90 * Returns the maximum number of journal log entries to batch on recovery before applying.
92 * @return the maximum number of journal log entries.
94 int getJournalRecoveryLogBatchSize();
97 * Returns the interval in which the leader needs to check if its isolated.
99 * @return the interval in ms.
101 long getIsolatedCheckIntervalInMillis();
105 * Returns the multiplication factor to be used to determine the shard election timeout. The election timeout
106 * is determined by multiplying the election timeout factor with the heart beat duration.
108 * @return the election timeout factor.
110 long getElectionTimeoutFactor();
114 * Returns the RaftPolicy used to determine certain Raft behaviors.
116 * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
118 @NonNull RaftPolicy getRaftPolicy();
121 * Returns the PeerAddressResolver.
123 * @return the PeerAddressResolver instance.
125 @NonNull PeerAddressResolver getPeerAddressResolver();
128 * Returns the custom RaftPolicy class name.
130 * @return the RaftPolicy class name or null if none set.
132 String getCustomRaftPolicyImplementationClass();
135 * Returns the directory in which to create temp files.
137 * @return the directory in which to create temp files.
139 @NonNull String getTempFileDirectory();
142 * Returns the threshold in terms of number of bytes when streaming data before it should switch from storing in
143 * memory to buffering to a file.
145 * @return the threshold in terms of number of bytes.
147 int getFileBackedStreamingThreshold();
150 * Returns the threshold in terms of number journal entries that we can lag behind a leader until we raise a
151 * 'not synced' transition.
153 * @return the threshold in terms of number of journal entries.
155 long getSyncIndexThreshold();