BUG 2185 : Make the Custom Raft Policy externally configurable
[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.opendaylight.controller.cluster.raft.policy.RaftPolicy;
11 import scala.concurrent.duration.FiniteDuration;
12
13 /**
14  * Configuration Parameter interface for configuring the Raft consensus system
15  * <p/>
16  * Any component using this implementation might want to provide an implementation of
17  * this interface to configure
18  *
19  * A default implementation will be used if none is provided.
20  *
21  * @author Kamal Rameshan
22  */
23 public interface ConfigParams {
24     /**
25      * The minimum number of entries to be present in the in-memory Raft log
26      * for a snapshot to be taken
27      *
28      * @return long
29      */
30     long getSnapshotBatchCount();
31
32     /**
33      * The percentage of total memory in the in-memory Raft log before a snapshot
34      * is to be taken
35      *
36      * @return int
37      */
38     int getSnapshotDataThresholdPercentage();
39
40     /**
41      * The interval at which a heart beat message will be sent to the remote
42      * RaftActor
43      *
44      * @return FiniteDuration
45      */
46     FiniteDuration getHeartBeatInterval();
47
48     /**
49      * The interval in which a new election would get triggered if no leader is found
50      *
51      * Normally its set to atleast twice the heart beat interval
52      *
53      * @return FiniteDuration
54      */
55     FiniteDuration getElectionTimeOutInterval();
56
57     /**
58      * The maximum election time variance. The election is scheduled using both
59      * the Election Timeout and Variance
60      *
61      * @return int
62      */
63     int getElectionTimeVariance();
64
65     /**
66      * The size (in bytes) of the snapshot chunk sent from Leader
67      */
68     int getSnapshotChunkSize();
69
70     /**
71      * The number of journal log entries to batch on recovery before applying.
72      */
73     int getJournalRecoveryLogBatchSize();
74
75     /**
76      * The interval in which the leader needs to check itself if its isolated
77      * @return FiniteDuration
78      */
79     long getIsolatedCheckIntervalInMillis();
80
81
82     /**
83      * The multiplication factor to be used to determine shard election timeout. The election timeout
84      * is determined by multiplying the election timeout factor with the heartbeat duration.
85      */
86     long getElectionTimeoutFactor();
87
88
89     /**
90      *
91      * @return An instance of org.opendaylight.controller.cluster.raft.policy.RaftPolicy or an instance of the
92      * DefaultRaftPolicy
93      */
94     RaftPolicy getRaftPolicy();
95 }