Bug 7391: Fix out-of-order LeaderStateChange events
[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 javax.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     /**
28      * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
29      *
30      * @return the minimum number of entries.
31      */
32     long getSnapshotBatchCount();
33
34     /**
35      * Returns the percentage of total memory used in the in-memory Raft log before a snapshot should be taken.
36      *
37      * @return the percentage.
38      */
39     int getSnapshotDataThresholdPercentage();
40
41     /**
42      * Returns the interval at which a heart beat message should be sent to remote followers.
43      *
44      * @return the interval as a FiniteDuration.
45      */
46     FiniteDuration getHeartBeatInterval();
47
48     /**
49      * Returns the interval after which a new election should be triggered if no leader is available.
50      *
51      * @return the interval as a FiniteDuration.
52      */
53     FiniteDuration getElectionTimeOutInterval();
54
55     /**
56      * Returns the maximum election time variance. The election is scheduled using both the election timeout
57      * and variance.
58      *
59      * @return the election time variance.
60      */
61     int getElectionTimeVariance();
62
63     /**
64      * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
65      *
66      * @return the maximum size (in bytes).
67      */
68     int getSnapshotChunkSize();
69
70     /**
71      * Returns the maximum number of journal log entries to batch on recovery before applying.
72      *
73      * @return the maximum number of journal log entries.
74      */
75     int getJournalRecoveryLogBatchSize();
76
77     /**
78      * Returns the interval in which the leader needs to check if its isolated.
79      *
80      * @return the interval in ms.
81      */
82     long getIsolatedCheckIntervalInMillis();
83
84
85     /**
86      * Returns the multiplication factor to be used to determine the shard election timeout. The election timeout
87      * is determined by multiplying the election timeout factor with the heart beat duration.
88      *
89      * @return the election timeout factor.
90      */
91     long getElectionTimeoutFactor();
92
93
94     /**
95      * Returns the RaftPolicy used to determine certain Raft behaviors.
96      *
97      * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
98      */
99     @Nonnull
100     RaftPolicy getRaftPolicy();
101
102     /**
103      * Returns the PeerAddressResolver.
104      *
105      * @return the PeerAddressResolver instance.
106      */
107     @Nonnull
108     PeerAddressResolver getPeerAddressResolver();
109
110     /**
111      * Returns the custom RaftPolicy class name.
112      *
113      * @return the RaftPolicy class name or null if none set.
114      */
115     String getCustomRaftPolicyImplementationClass();
116
117 }