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