2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.raft;
10 import javax.annotation.Nonnull;
11 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
12 import scala.concurrent.duration.FiniteDuration;
15 * Configuration Parameter interface for configuring the Raft consensus system
18 * Any component using this implementation might want to provide an implementation of
19 * this interface to configure
22 * A default implementation will be used if none is provided.
24 * @author Kamal Rameshan
26 public interface ConfigParams {
27 int MEGABYTE = 1048576;
30 * Returns the minimum number of entries to be present in the in-memory Raft log for a snapshot to be taken.
32 * @return the minimum number of entries.
34 long getSnapshotBatchCount();
37 * Returns the percentage of total memory used in the in-memory Raft log before a snapshot should be taken.
39 * @return the percentage.
41 int getSnapshotDataThresholdPercentage();
44 * Returns the interval at which a heart beat message should be sent to remote followers.
46 * @return the interval as a FiniteDuration.
48 FiniteDuration getHeartBeatInterval();
51 * Returns the interval after which a new election should be triggered if no leader is available.
53 * @return the interval as a FiniteDuration.
55 FiniteDuration getElectionTimeOutInterval();
58 * Returns the maximum election time variance. The election is scheduled using both the election timeout
61 * @return the election time variance.
63 int getElectionTimeVariance();
66 * Returns the maximum size (in bytes) for the snapshot chunk sent from a Leader.
68 * @return the maximum size (in bytes).
70 int getSnapshotChunkSize();
73 * Returns the maximum number of journal log entries to batch on recovery before applying.
75 * @return the maximum number of journal log entries.
77 int getJournalRecoveryLogBatchSize();
80 * Returns the interval in which the leader needs to check if its isolated.
82 * @return the interval in ms.
84 long getIsolatedCheckIntervalInMillis();
88 * Returns the multiplication factor to be used to determine the shard election timeout. The election timeout
89 * is determined by multiplying the election timeout factor with the heart beat duration.
91 * @return the election timeout factor.
93 long getElectionTimeoutFactor();
97 * Returns the RaftPolicy used to determine certain Raft behaviors.
99 * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy.
102 RaftPolicy getRaftPolicy();
105 * Returns the PeerAddressResolver.
107 * @return the PeerAddressResolver instance.
110 PeerAddressResolver getPeerAddressResolver();
113 * Returns the custom RaftPolicy class name.
115 * @return the RaftPolicy class name or null if none set.
117 String getCustomRaftPolicyImplementationClass();
120 * Returns the directory in which to create temp files.
122 * @return the directory in which to create temp files.
125 String getTempFileDirectory();
128 * Returns the threshold in terms of number of bytes when streaming data before it should switch from storing in
129 * memory to buffering to a file.
131 * @return the threshold in terms of number of bytes.
133 int getFileBackedStreamingThreshold();