8351374d60fe0e73bb5ca2fbfa2ea01cbd5a3f52
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / ConfigParams.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.raft;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
12 import scala.concurrent.duration.FiniteDuration;
13
14 /**
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
17  * is provided.
18  *
19  * @author Kamal Rameshan
20  */
21 public interface ConfigParams {
22     int MEGABYTE = 1048576;
23
24     /**
25      * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
26      *
27      * @return the minimum number of entries.
28      */
29     long getSnapshotBatchCount();
30
31     /**
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.
34      *
35      * @return the percentage.
36      */
37     int getSnapshotDataThresholdPercentage();
38
39     /**
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.
42      *
43      * @return maximum journal size (in MiB).
44      */
45     int getSnapshotDataThreshold();
46
47     /**
48      * Returns the interval(in seconds) after which a snapshot should be taken during recovery. Negative value means
49      * do not take snapshots.
50      *
51      * @return the interval of recovery snapshot in seconds
52      */
53     int getRecoverySnapshotIntervalSeconds();
54
55     /**
56      * Returns the interval at which a heart beat message should be sent to remote followers.
57      *
58      * @return the interval as a FiniteDuration.
59      */
60     FiniteDuration getHeartBeatInterval();
61
62     /**
63      * Returns the interval after which a new election should be triggered if no leader is available.
64      *
65      * @return the interval as a FiniteDuration.
66      */
67     FiniteDuration getElectionTimeOutInterval();
68
69     /**
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.
72      *
73      * @return the interval as a FiniteDuration.
74      */
75     long getCandidateElectionTimeoutDivisor();
76
77     /**
78      * Returns the maximum election time variance. The election is scheduled using both the election timeout
79      * and variance.
80      *
81      * @return the election time variance.
82      */
83     int getElectionTimeVariance();
84
85     /**
86      * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
87      *
88      * @return the maximum size (in bytes).
89      */
90     int getSnapshotChunkSize();
91
92     /**
93      * Returns the maximum number of journal log entries to batch on recovery before applying.
94      *
95      * @return the maximum number of journal log entries.
96      */
97     int getJournalRecoveryLogBatchSize();
98
99     /**
100      * Returns the interval in which the leader needs to check if its isolated.
101      *
102      * @return the interval in ms.
103      */
104     long getIsolatedCheckIntervalInMillis();
105
106     /**
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.
109      *
110      * @return the election timeout factor.
111      */
112     long getElectionTimeoutFactor();
113
114     /**
115      * Returns the RaftPolicy used to determine certain Raft behaviors.
116      *
117      * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
118      */
119     @NonNull RaftPolicy getRaftPolicy();
120
121     /**
122      * Returns the PeerAddressResolver.
123      *
124      * @return the PeerAddressResolver instance.
125      */
126     @NonNull PeerAddressResolver getPeerAddressResolver();
127
128     /**
129      * Returns the custom RaftPolicy class name.
130      *
131      * @return the RaftPolicy class name or null if none set.
132      */
133     String getCustomRaftPolicyImplementationClass();
134
135     /**
136      * Returns the directory in which to create temp files.
137      *
138      * @return the directory in which to create temp files.
139      */
140     @NonNull String getTempFileDirectory();
141
142     /**
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.
145      *
146      * @return the threshold in terms of number of bytes.
147      */
148     int getFileBackedStreamingThreshold();
149
150     /**
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.
153      *
154      * @return the threshold in terms of number of journal entries.
155      */
156     long getSyncIndexThreshold();
157 }