Bump versions to 2.0.3-SNAPSHOT
[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
16  *
17  * <p>
18  * Any component using this implementation might want to provide an implementation of
19  * this interface to configure
20  *
21  * <p>
22  * A default implementation will be used if none is provided.
23  *
24  * @author Kamal Rameshan
25  */
26 public interface ConfigParams {
27     int MEGABYTE = 1048576;
28
29     /**
30      * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
31      *
32      * @return the minimum number of entries.
33      */
34     long getSnapshotBatchCount();
35
36     /**
37      * Returns the percentage of total memory used in the in-memory Raft log before a snapshot should be taken.
38      *
39      * @return the percentage.
40      */
41     int getSnapshotDataThresholdPercentage();
42
43     /**
44      * Returns the interval at which a heart beat message should be sent to remote followers.
45      *
46      * @return the interval as a FiniteDuration.
47      */
48     FiniteDuration getHeartBeatInterval();
49
50     /**
51      * Returns the interval after which a new election should be triggered if no leader is available.
52      *
53      * @return the interval as a FiniteDuration.
54      */
55     FiniteDuration getElectionTimeOutInterval();
56
57     /**
58      * Returns the number by which a candidate should divide the election timeout it has calculated. This serves
59      * to speed up retries when elections result in a stalemate.
60      *
61      * @return the interval as a FiniteDuration.
62      */
63     long getCandidateElectionTimeoutDivisor();
64
65     /**
66      * Returns the maximum election time variance. The election is scheduled using both the election timeout
67      * and variance.
68      *
69      * @return the election time variance.
70      */
71     int getElectionTimeVariance();
72
73     /**
74      * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
75      *
76      * @return the maximum size (in bytes).
77      */
78     int getSnapshotChunkSize();
79
80     /**
81      * Returns the maximum number of journal log entries to batch on recovery before applying.
82      *
83      * @return the maximum number of journal log entries.
84      */
85     int getJournalRecoveryLogBatchSize();
86
87     /**
88      * Returns the interval in which the leader needs to check if its isolated.
89      *
90      * @return the interval in ms.
91      */
92     long getIsolatedCheckIntervalInMillis();
93
94
95     /**
96      * Returns the multiplication factor to be used to determine the shard election timeout. The election timeout
97      * is determined by multiplying the election timeout factor with the heart beat duration.
98      *
99      * @return the election timeout factor.
100      */
101     long getElectionTimeoutFactor();
102
103
104     /**
105      * Returns the RaftPolicy used to determine certain Raft behaviors.
106      *
107      * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
108      */
109     @NonNull RaftPolicy getRaftPolicy();
110
111     /**
112      * Returns the PeerAddressResolver.
113      *
114      * @return the PeerAddressResolver instance.
115      */
116     @NonNull PeerAddressResolver getPeerAddressResolver();
117
118     /**
119      * Returns the custom RaftPolicy class name.
120      *
121      * @return the RaftPolicy class name or null if none set.
122      */
123     String getCustomRaftPolicyImplementationClass();
124
125     /**
126      * Returns the directory in which to create temp files.
127      *
128      * @return the directory in which to create temp files.
129      */
130     @NonNull String getTempFileDirectory();
131
132     /**
133      * Returns the threshold in terms of number of bytes when streaming data before it should switch from storing in
134      * memory to buffering to a file.
135      *
136      * @return the threshold in terms of number of bytes.
137      */
138     int getFileBackedStreamingThreshold();
139
140     /**
141      * Returns the threshold in terms of number journal entries that we can lag behind a leader until we raise a
142      * 'not synced' transition.
143      *
144      * @return the threshold in terms of number of journal entries.
145      */
146     long getSyncIndexThreshold();
147 }