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. Any component using this implementation
16 * might want to provide an implementation of this interface to configure. A default implementation will be used if none
19 * @author Kamal Rameshan
21 public interface ConfigParams {
22 int MEGABYTE = 1048576;
25 * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
27 * @return the minimum number of entries.
29 long getSnapshotBatchCount();
32 * Returns the percentage of total memory used in the in-memory Raft log before a snapshot should be taken.
33 * Disabled when direct threshold is enabled.
35 * @return the percentage.
37 int getSnapshotDataThresholdPercentage();
40 * Returns the max size of memory used in the in-memory Raft log before a snapshot should be taken. 0 means that
41 * direct threshold is disabled and percentage is used instead.
43 * @return maximum journal size (in MiB).
45 int getSnapshotDataThreshold();
48 * Returns the interval(in seconds) after which a snapshot should be taken during recovery. Negative value means
49 * do not take snapshots.
51 * @return the interval of recovery snapshot in seconds
53 int getRecoverySnapshotIntervalSeconds();
56 * Returns the interval at which a heart beat message should be sent to remote followers.
58 * @return the interval as a FiniteDuration.
60 FiniteDuration getHeartBeatInterval();
63 * Returns the interval after which a new election should be triggered if no leader is available.
65 * @return the interval as a FiniteDuration.
67 FiniteDuration getElectionTimeOutInterval();
70 * Returns the number by which a candidate should divide the election timeout it has calculated. This serves
71 * to speed up retries when elections result in a stalemate.
73 * @return the interval as a FiniteDuration.
75 long getCandidateElectionTimeoutDivisor();
78 * Returns the maximum election time variance. The election is scheduled using both the election timeout
81 * @return the election time variance.
83 int getElectionTimeVariance();
86 * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
88 * @return the maximum size (in bytes).
90 int getSnapshotChunkSize();
93 * Returns the maximum number of journal log entries to batch on recovery before applying.
95 * @return the maximum number of journal log entries.
97 int getJournalRecoveryLogBatchSize();
100 * Returns the interval in which the leader needs to check if its isolated.
102 * @return the interval in ms.
104 long getIsolatedCheckIntervalInMillis();
107 * Returns the multiplication factor to be used to determine the shard election timeout. The election timeout
108 * is determined by multiplying the election timeout factor with the heart beat duration.
110 * @return the election timeout factor.
112 long getElectionTimeoutFactor();
115 * Returns the RaftPolicy used to determine certain Raft behaviors.
117 * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
119 @NonNull RaftPolicy getRaftPolicy();
122 * Returns the PeerAddressResolver.
124 * @return the PeerAddressResolver instance.
126 @NonNull PeerAddressResolver getPeerAddressResolver();
129 * Returns the custom RaftPolicy class name.
131 * @return the RaftPolicy class name or null if none set.
133 String getCustomRaftPolicyImplementationClass();
136 * Returns the directory in which to create temp files.
138 * @return the directory in which to create temp files.
140 @NonNull String getTempFileDirectory();
143 * Returns the threshold in terms of number of bytes when streaming data before it should switch from storing in
144 * memory to buffering to a file.
146 * @return the threshold in terms of number of bytes.
148 int getFileBackedStreamingThreshold();
151 * Returns the threshold in terms of number journal entries that we can lag behind a leader until we raise a
152 * 'not synced' transition.
154 * @return the threshold in terms of number of journal entries.
156 long getSyncIndexThreshold();